如何取得DataGrid中自建DropDownList的值?
偶的DataGrid是动态邦定列的,并使用了按钮列之编辑列。编辑时将某列由原来的TextBox转换为DropDownList,代码如下:
DropDownList ddl = new DropDownList();
//ddl填入值
e.Item.Cells[i].Controls.RemoveAt(0);
e.Item.Cells[i].Controls.AddAt(0,ddl);
但是,在偶"更新"时,使用DropDownList ddl=(DropDownList)e.Item.Cells[i].Controls[0];却找不到DropDownList!(异常信息: System.InvalidCastException: 指定的转换无效。).跟踪调试发现e.Item.Cells[i].Controls[0]的类型竟依然是TextBox???!!!
Why?
各位老大,哪里错了?咋个办呢???????????????