本文介绍了从一个drpdown复制到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个下拉菜单dr1,dr2和一个按钮. dr1包含项目.我希望当我从dr1中选择一个项目并单击按钮时,必须将选定的项目复制到dr2中.当我从dr1中选择item2并再次按下按钮时,它将将该项目复制到dr2中.我已经使用了代码,但我无法正常工作并给出错误.有人可以告诉我我该怎么做.
i have two dropdowns dr1,dr2 and a button. dr1 contains items. i want that when i select an item from dr1 and click on button so that selected item must be coppied into dr2. when i select item2 from dr1 and press the button again it copies that item into dr2. i have used a code but i doesnt work and gives and error. can somebody tell me what i need to do.
protected void Button1_Click(object sender, EventArgs e) { DropDownList2.Items.Add(DropDownList1.SelectedItem); }推荐答案
您可以在CP上查看该文章; ASP.NET中的多选下拉列表 [ ^ ] 这将帮助您从下拉菜单中选择多个项目.如果您不想使用此功能,则可以使用列表框. 祝你好运. You can look at that article on CP; Multi select Dropdown list in ASP.NET[^] This will help you select multiple items from a drop down. If you do not want to use this, instead you can use a listbox. Good luck.
尝试一下: Try this: DropDownList2.Items.Add(DropDownList1.Items[DropDownList1.SelectedIndex]);
您*可能*需要先这样做:
You *might* need to do this first:
DropDownList2.SelectedIndex = -1;
更多推荐
从一个drpdown复制到另一个
发布评论