日期:2011-03-12  浏览次数:20414 次

public void DataGrid1_Edit(object sender,DataGridCommandEventArgs e)
        {            
            string strSql;
            string ConnectionString;
            ConnectionString = ConfigurationSettings.AppSettings["ConnectionString"];
            DataGrid1.EditItemIndex =(int)e.Item.ItemIndex;    
            BindGrid();                        
            DropDownList ddl = (DropDownList)(DataGrid1.Items[e.Item .ItemIndex].Cells [4].Controls [1]);
            strSql = "select WorkState,ItemNumber from ASP_Temp";    

            OleDbConnection myconn=new OleDbConnection(ConnectionString );
            OleDbCommand mycommand=new OleDbCommand (strSql,myconn);    
            myconn.Open();            
            OleDbDataReader myreader=mycommand.ExecuteReader();
                
            ddl.DataSource =myreader;
            ddl.DataTextField ="WorkState";
            ddl.DataValueField = "ItemNumber";
            ddl.DataBind ();    
            myreader.Close();
            myconn.Close();            
        }