我有一个下拉列表框,其中一个值是其他值。我想把这些值移到最后。请在这件事上给予我帮助。我使用的代码如下
ddlAssetsCountryOthersone.DataSource = lstIMAssetsByCountryOthers;
ddlAssetsCountryOthersone.DataTextField = "AssetDescription";
ddlAssetsCountryOthersone.DataValueField = "AssetDescription";
ddlAssetsCountryOthersone.DataBind();
ddlAssetsCountryOthersone.Items.Remove(
ddlAssetsCountryOthersone.Items.FindByValue(
Constants.PhilosophyAndEmphasis.Other.ToString()));
如何将其他人添加回最后的下拉列表
最佳答案
在你的数据绑定(bind)之后试试这个:
ddlAssetsCountryOthersone.Items.Add(new ListItem("Others", "Others"));
顺便说一句,如果你使用Insert方法,你可以将你想要的项目插入到你想要的位置。例如,下面的代码将 Other 选项添加到第四顺序:
ddlAssetsCountryOthersone.Items.Insert(4, new ListItem("Others", "Others"));
关于c# - 向下拉列表框添加新值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1741736/