重新安排DropDownValues [英] Re-Arrange the DropDownValues

查看:96
本文介绍了重新安排DropDownValues的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



每个人

我有一个 DropDownList ,在删除"按钮上,单击下拉列表中的数字将被删除,在添加"按钮上,单击编号被添加到下拉列表中.

现在,如果下拉菜单中有1、2、3,并且删除了1,我希望将数字2和3替换为1和2.我不确定如何执行此操作.有人可以帮我吗?

Hi ,

EveryOne

I have a DropDownList ,On a Delete button click the numbers from the dropdown get deleted and and on Add Button click numbers are added to the dropdown.

Now if have 1, 2, 3 in my dropdown and if I delete 1, I want the number 2 and 3 to be replaced by 1 and 2. I am not sure how to do this. Can someone please help me?

推荐答案


首先获取下拉列表的数据源,对其进行排序,然后再次将数据源设置为下拉列表.
试试这个:
Hi,
First get the datasouce of your dropdownlist, sort it and set the datasouce again to the dropdownlist.
Try this:
DataTable dt = (DataTable)DropDownList1.DataSource;
//Sort your datatable here.
dt.DefaultView.Sort = "Parameter_Name ASC";
dt = dt.DefaultView.ToTable();
DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "Description";
DropDownList1.DataValueField = "Code";
DropDownList1.DataBind();





--Amit





--Amit


pls参见此处:
http://www.eggheadcafe.com/community/csharp/2/10091141/remove-selected-items-from-dropdownlist.aspx [
pls see here:
http://www.eggheadcafe.com/community/csharp/2/10091141/remove-selected-items-from-dropdownlist.aspx[^]


这篇关于重新安排DropDownValues的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆