对DataGrid1进行数据绑定后,执行以下语句,dl却是空的,为什么呢?
DropDownList dl=(DropDownList)DataGrid1.Items[0].FindControl("DropDownList1");
不管是放在private void Page_Load(object sender,System.EventArgs e)
{
}中,还是模板列中编辑按钮被按下时
private void DataGrid1_EditCommand(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
}中,都是空的.
请问,怎么进行Item行的类别判断呢?
不管是放在private void Page_Load(object sender,System.EventArgs e)
{
}中,还是模板列中编辑按钮被按下时
private void DataGrid1_EditCommand(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
}中,都是空的.
请问,怎么进行Item行的类别判断呢?
if(e.Item.ItemType == ListItemType.Item ||e.Item.ItemType == ListItemType.AlternatingItem)
{
DropDownList dl=(DropDownList)DataGrid1.Items[0].FindControl("DropDownList1");
}