.net 里的DropDownList下拉框里的选项 怎么样才能输入个数字或字母自动选中?

2024-12-27 00:54:45
推荐回答(3个)
回答1:

protected void TextBox1_TextChanged(object sender, EventArgs e)
{
for (int i = 0; i < DropDownList1.Items.Count; i++)
{
if (TextBox1.Text == DropDownList1.Items[i].Text)
{
DropDownList1.Items[i].Selected = true;
}
}
}

回答2:

public void autoSelect(DropDownList dl, string value)
{
for (int i = 0; i < dl.Items.Count; i++)
{
if (dl.Items[i].Text == value)
dl.Items[i].Selected = true;
}
}

回答3:

输入input 51210