我试图在添加数据绑定后将“请选择”项添加到我的下拉列表中,但是它似乎不起作用。这就是我正在尝试的
ddlListMine.Items.Add(new ListItem("Please Please Please Select....", "-1"));
ddlListMine.DataSource = GetSomeChickens();
ddListMine.DataTextField = "ChickenName";
ddListMine.DataValueField= "NumberOfEggsChickenLay";
ddListMine.DataBind();
我还尝试将第一行代码移到最后一行,但是下拉列表的末尾出现了“ Please Please ...”项。
最佳答案
将商品插入Oth Index
ddlListMine.DataSource = GetSomeChickens();
ddListMine.DataTextField = "ChickenName";
ddListMine.DataValueField= "NumberOfEggsChickenLay";
ddListMine.Items.Insert(0, new ListItem("Please Please Please Select....", "0"));
ddListMine.DataBind();