h1

Find a ‘Value’ or ‘Text’ is Exist in ASP DropDownList

October 21, 2010

If the ‘Value’ or ‘Text’ is not Exist it throws the error. We can find that item is exist in that DropDownList or not.

Code:

ListItem Item1 = drpLst.Items.FindByValue(“value”);
//or
ListItem Item1 = drpLst.Items.FindByText(“text”); 

if (Item1 == null)
{
//Not Exist
}
else
{
//Exist
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: