[英]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.