下拉列表的绑定(代码后置).txt
来自「C# 是创新性的新式编程语言」· 文本 代码 · 共 20 行
TXT
20 行
1.编辑时绑定下拉列表的选定
要点:
a.要命名隐藏列变为只读状态(属性生成器|列|选定列勾选只读),否则e.Item.Cells[count-2].Text总为空.
private void Datagridex2_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.EditItem)//编辑状态
{
int count = this.Datagridex2.Columns.Count;
if(e.Item.Cells[count-2].Text=="0")
{
((DropDownList)e.Item.Cells[count-7].FindControl("DDLevel")).SelectedIndex=0;
}
else
{
((DropDownList)e.Item.Cells[count-7].FindControl("DDLevel")).SelectedIndex=1;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?