本文介绍了添加项目到下拉列表不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个下拉列表中有一个奇怪的问题。
它有数据绑定项目并依赖于另一个下拉列表。
因此,如果我从第一个下拉列表中选择一个值,那么这个下拉列表将包含数据绑定项。
我的问题我有的是我想在索引0处添加一个值为ALL的值,并在显示数据绑定项后显示但这不起作用。我有它在这个下面的其他下拉菜单工作。
这里是我的代码:
Hi,
I have a weird issue on one drop down list.
It has databound items and is dependant on another dropdownlist.
So if I select a value from the 1st dropdown list then this dropdownlist in question will have databound items.
the issue that I am having is that I want to add a value at index 0 that says "ALL" and there after display the databound items but this is not working. I have it working for the rest of the dropdowns beside this 1.
here is my code:
ddlPromoSuffEdit.Items.Clear();
ddlPromoSuffEdit.Items.Add(new ListItem("All", "")); //this is not being added in but data items are populated
ddlPromoSuffEdit.DataSourceID = "";
ddlPromoSuffEdit.DataSource = odsPromoSuffEdit.Select();
ddlPromoSuffEdit.DataBind();
推荐答案
ddlPromoSuffEdit.Items.Clear();
ddlPromoSuffEdit.DataSourceID = "";
ddlPromoSuffEdit.DataSource = odsPromoSuffEdit.Select();
ddlPromoSuffEdit.DataBind();
//Insert new ListItem ...
ddlPromoSuffEdit.Items.Insert(0, (new ListItem("All", "")));
...希望它有所帮助。
... hope it helps.
这篇关于添加项目到下拉列表不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!