DataGrid 里按钮列 e.Item.Cells[0].Controls[0] 怎么无法获取对象?
我新建的DataSet,绑定到DataGrid里
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add();
dt.Columns.Add("Object",typeof(object));
dt.Columns.Add("Airways",typeof(string));
dt.Columns.Add("FN",typeof(string));
dt.Columns.Add("Ptype",typeof(string));
dt.Columns.Add("Sites",typeof(object));
添加了一行按钮列,希望实现:
private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName == "Select")
{
object clsSegment = e.Item.Cells[0].Controls[0];
Module.clsSegmentData cls = (Module.clsSegmentData)clsSegment;
string str = clsSegment.ToString();
string sr= cls.Ptype;
string sfdf = "df";
}
}
可是一到这
object clsSegment = e.Item.Cells[0].Controls[0];
就获取不了对象
e.Item.Cells[0].Controls.Count = 0;
e.Item.Cells[0].Text 是有值的。