[英]Dropdownlist with button when button click popup opened
你能告訴我怎么做這個嗎? 我有一個DropDownList
, DropDownList
填充了ListItems
。 在DropDownList
,有一個名為ADD NEW的Button
。 單擊該按鈕時,會打開一個彈出窗口。 如果項目不在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.