从一个drpdown复制到另一个

编程入门 行业动态 更新时间:2024-10-25 16:24:06
本文介绍了从一个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复制到另一个

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

发布评论

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

>www.elefans.com

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