向下拉列表框添加新值

Sum*_*esh 2 .net c# asp.net drop-down-menu

我有一个下拉列表框,其中一个值为其他值。我想将这些值移到最后。请帮我解决一下这个。我使用的代码如下

ddlAssetsCountryOthersone.DataSource = lstIMAssetsByCountryOthers;
ddlAssetsCountryOthersone.DataTextField = "AssetDescription";
ddlAssetsCountryOthersone.DataValueField = "AssetDescription";
ddlAssetsCountryOthersone.DataBind();
ddlAssetsCountryOthersone.Items.Remove(
             ddlAssetsCountryOthersone.Items.FindByValue(
                Constants.PhilosophyAndEmphasis.Other.ToString()));
Run Code Online (Sandbox Code Playgroud)

我如何将其他人添加回最后的下拉列表

Can*_*var 5

在你的数据绑定后试试这个:

ddlAssetsCountryOthersone.Items.Add(new ListItem("Others", "Others"));
Run Code Online (Sandbox Code Playgroud)

顺便说一句,如果您使用插入方法,您可以将您想要的项目插入到您想要的位置。例如,下面的代码将 Other 选项添加到 4th order :

ddlAssetsCountryOthersone.Items.Insert(4, new ListItem("Others", "Others"));
Run Code Online (Sandbox Code Playgroud)