动态绑定DropDownList,如何在列头在手动添加一列?

2025-01-06 16:44:47
推荐回答(3个)
回答1:

这段代码放在DropDownList数据绑定下面:
DropDownListId.Items.Insert(0, new ListItem("请选择", ""));

回答2:

ListItem[] NewList = new ListItem[1];
NewList[0] = new ListItem("请选择", "");
YourDropDownList.Items.AddRange(NewList);
YourDropDownList 是你的DropDownList

回答3:

Table = kdbll.SelectKnowlegecode(strIPCode);
Table.Rows.InsertAt(Table.NewRow(), 0);
Table.Rows[0][0] = "";
Table.Rows[0][1] = "";
Table.Rows[0][2] = "请选择";
Table.Rows[0][3] = "0";
this.comKnowledge5.DataSource = Table;
this.comKnowledge5.DisplayMember = "Name";
this.comKnowledge5.ValueMember = "ID";