添加一个新值下拉列表框中框中、列表

2023-09-04 05:14:32 作者:爲妳心甘情願

我有一个下拉列表框,其中有一个值是别人。我想将这些值到最后。请帮我这个。在code我现在用的就是如下:

I have a drop down list box which has one of the values to be others. I want to move these value to the last. Please help me with this. The code i am using is as follows

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

我怎么能增加别人回的下拉列表中的最后一个

How can i add the others back to the drop down list in the last

推荐答案

试试这个您的数据绑定后:

try this after your databind :

ddlAssetsCountryOthersone.Items.Add(new ListItem("Others", "Others"));

通过,如果你使用的方法插入的方式,你可以插入你要你想要的位置的项目。例如,code以下添加其他选项到4阶:

By the way if you use Insert method, you can insert the item you want to the position you want. For example the code below adds the Other option to the 4th order :

ddlAssetsCountryOthersone.Items.Insert(4, new ListItem("Others", "Others"));