简体   繁体   中英

Dropdownlist with button when button click popup opened

Can you please give me a clue how to do this? I have a DropDownList , that DropDownList is filled with ListItems . After the DropDownList , there's a Button called ADD NEW . When the button is clicked, a popup opened. If an item is not in the DropDownList , I wanted to add it. In popup box window there's a TextBox and add Button .

Basically, If an item is not in DropDownlist I want to add it by clicking the ADD NEW button.

Something on the following line...

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

In popup when you enter the item and press add button just do the following steps:

 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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