使用下拉列表 [英] Working with dropdownlists
本文介绍了使用下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨极客,
只是小验证。
我需要加载选择在pageload下拉列表。
然后我在文本框中输入后添加一个项目。
Hi geeks,
Just small verification.
I need to load "Select" in dropdownlist at pageload.
Then later on I add an item after typed in textbox.
DropDownList d2 = (DropDownList)gvrow.Cells[2].FindControl("ddlfabric");
d2.Items.Insert(0, new ListItem("Select"));
if (txtfabric.Text != "")
{
if(!d2.Items.Contains(new ListItem(txtfabric.Text)))
{
d2.Items.Insert(1, txtfabric.Text);
}
}
删除重复项但不删除选择一词。为什么选择重复???
The duplicates are removed but not the word "Select". Why Select is repeated ???
推荐答案
在Page_Load()
In Page_Load()
if (!Page.IsPostBack)
{
//Add your "Select" Item here.
}
这篇关于使用下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文