繁体   English   中英

打开按钮单击弹出窗口时带按钮的下拉列表

[英]Dropdownlist with button when button click popup opened

你能告诉我怎么做这个吗? 我有一个DropDownListDropDownList填充了ListItems DropDownList ,有一个名为ADD NEWButton 单击该按钮时,会打开一个弹出窗口。 如果项目不在DropDownList ,我想添加它。 在弹出框窗口中有一个TextBox并添加Button

基本上,如果项目不在DropDownlist我想通过单击ADD NEW按钮添加它。

以下内容......

string newItem = textbox1.Text;
if(ddlMyList.Items.FindByText(newItem) == null) //Means item not found
    {
    ddlMyList.Items.Add(new ListItem(newItem));
    }

在弹出窗口中输入项目并按添加按钮时,只需执行以下步骤:

 1. Iterate through all the elements in dropdown and check if item you want to add exist or not
 2. If item does not exist then add it to dropdown using this code:
     yourDropdown.items.Add(newitem);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM