Thursday, February 16, 2012

To Check if the dropdownlist has a given value before selecting it

To Check if the dropdownlist has a given value before selecting it:

ListItem li = ddlItems.Items.FindByValue(MyNr.ToString());
if (li != null) //Item Found in dropdown..so select it and display details
{
//Value was found
}
else
{ //not found }

No comments: