vs2003的datagrid问题

这是一个例子,你可以看看,不懂可以留言
private   void   DataGrid1_ItemDataBound(object   sender,   System.Web.UI.WebControls.DataGridItemEventArgs   e)  
  {  
  if   (e.Item.ItemType   ==   ListItemType.Item    
          ||   e.Item.ItemType   ==   ListItemType.AlternatingItem)    
  {  
  SqlConnection   sc=new   SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["constr"]);  
  sc.Open();  
  SqlCommand   cmd=new   SqlCommand("select   *   from   usertypeInfo",sc);  
   
  SqlDataReader   dr   =cmd.ExecuteReader();  
   
  ((DropDownList)(e.Item.FindControl("dd"))).DataSource=dr;  
  ((DropDownList)(e.Item.FindControl("dd"))).DataTextField="usertype";  
  ((DropDownList)(e.Item.FindControl("dd"))).DataValueField="usertypeID";  
  ((DropDownList)(e.Item.FindControl("dd"))).DataBind();  
  sc.Close();  
  }  
  }
}

原文地址:https://www.cnblogs.com/landy_mo/p/2130488.html