MS确实没有直接提供这样的功能,不过你可以在DataGrid的ItemDataBound事件中处理:
//设置第一列只读
if (e.Item.ItemIndex >= 0)
{
TextBox txt = (TextBox)e.Item.Cells[0].Controls[0];
txt.Visible = false;
e.Item.Cells[0].Controls.Add(new LiteralControl(txt.Text));
}//在第一列中添加DropDownList
if (e.Item.ItemIndex >= 0)
{
TextBox txt = (TextBox)e.Item.Cells[0].Controls[0];
txt.Visible = false;
DropDownList list = new DropDownList();
list.Items.Add("Item 1");
e.Item.Cells[0].Controls.Add(list);
}
//设置第一列只读
if (e.Item.ItemIndex >= 0)
{
TextBox txt = (TextBox)e.Item.Cells[0].Controls[0];
txt.Visible = false;
e.Item.Cells[0].Controls.Add(new LiteralControl(txt.Text));
}//在第一列中添加DropDownList
if (e.Item.ItemIndex >= 0)
{
TextBox txt = (TextBox)e.Item.Cells[0].Controls[0];
txt.Visible = false;
DropDownList list = new DropDownList();
list.Items.Add("Item 1");
e.Item.Cells[0].Controls.Add(list);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货