重新安排DropDownValues

编程入门 行业动态 更新时间:2024-10-19 01:21:32
本文介绍了重新安排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参见此处: www.eggheadcafe/community/csharp/2/10091141/remove-selected-items-from-dropdownlist.aspx [ ^ ] pls see here: www.eggheadcafe/community/csharp/2/10091141/remove-selected-items-from-dropdownlist.aspx[^]

更多推荐

重新安排DropDownValues

本文发布于:2023-07-14 09:58:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1104032.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:DropDownValues

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!