如何检查dropdownlist选择值是否存在? [英] how to check dropdownlist selected value is there or not ?
本文介绍了如何检查dropdownlist选择值是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查dropdownlist选择值是否存在?
解决方案
HI
您可以查看
ddlValue.Items.FindByText
试试这个...
你可以处理以这种方式
ListItem item = dropdownlist1.Items.FindByText( textValue跨度>);
if (item!= null )
{
dropdownlist1。 Items.FindByText( textValue)。Selected = true 跨度>;
}
或
if (dropdownlist1.Items.FindByText( textValue)!= null )
{
// ...此处代码
}
你也可以使用
FindByValue
如果你在winforms中使用c#,你可以这样做......
string strvalue = ddl1.selectedValue.ToString ();
how to check dropdownlist selected value is there or not ?
解决方案
HI
You can check like
ddlValue.Items.FindByText
try this ...
You can handle this in this way
ListItem item = dropdownlist1.Items.FindByText("textValue"); if (item != null) { dropdownlist1.Items.FindByText("textValue").Selected = true; }
Or
if (dropdownlist1.Items.FindByText("textValue") != null) { // ... code here }
You can also use
FindByValue
if you are using c# in winforms, you can do it like...
string strvalue = ddl1.selectedValue.ToString();
这篇关于如何检查dropdownlist选择值是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文