日期:2014-05-19  浏览次数:20488 次

关于gridview传值和excel导入到库的问题,高手门帮解决下!~
我在DataBound事件里写了点击某一行弹出窗口的代码,
但是要在弹出的这个页里获取gridview传过来的ID值,可是我在取gridview中的ID时,怎么也取不到
下面是代码;
  protected   void   GridView1_RowDataBound(object   sender,   GridViewRowEventArgs   e)
        {
                if   (e.Row.RowType   ==   DataControlRowType.DataRow)
                {
                        e.Row.Attributes.Add( "onmouseover ",   "this.style.backgroundColor= '#e7e7e7 ' ");
                        e.Row.Attributes.Add( "onmouseout ",   "this.style.backgroundColor= 'white ' ");
                }
                if   (e.Row.RowIndex   >   -1)
                {

                        e.Row.Attributes.Add( "onclick ",   "window.showModalDialog( 'test.aspx?index= "+this.GridView1.SelectedRow.RowIndex.ToString()+ " ') ");
//这行取ID值
                }
        }

在excel导入的时候老是提示找不到Sheet1$数据
下面是代码
string   filename   =   this.file1.FileName;
                  string   strCon;
                strCon   =   "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source= "+filename+ ";extended   Properties=Excel   8.0; ";
                OleDbConnection   olecon   =   new   OleDbConnection(strCon);
                OleDbDataAdapter   myda   =   new   OleDbDataAdapter( "select   *   from   [Sheet1$] ",   strCon);
                DataSet   myDs   =   new   DataSet();
                myda.Fill(myDs);
                if   (myDs.Tables[0].Rows.Count   >   0)
                {
                        string   strSql   =   " ";
                        string   CnnString   =   ConfigurationManager.AppSettings[ "SqlConnection "];
                        OleDbConnection   conn   =   new   OleDbConnection(CnnString);
                        conn.Open();
                        OleDbCommand   myCmd   =   null;

                        for   (int   i   =   0;   i   <   myDs.Tables[0].Rows.Count;   i++)