> ## Content Index
> Fetch the complete content index at: https://irishdotnet.dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to check if your drop down list contains a specific value using C#
- URL: https://irishdotnet.dev/how-to-check-if-your-drop-down-list-contains-a-specific-value-using-c/
- Published: 2009-09-23T23:00:00.000Z
- Updated: 2024-08-05T08:47:00.000Z
- Author: Richard Reddy
- Tags: C#

If you want to set the default value of a drop down list from a value being passed to you by a third party you should always include a check to ensure that your drop down contains the value so that you don't end up with some nasty compiler errors.

To keep things simple let's say I want to check if my drop down contains the value "MyValue". If it does I want to pre-select that option for the user. To do this I would use something like below:

``````
if (MyDropDownList.Items.FindByValue("MyValue") != null)
{
    MyDropDownList.SelectedValue = "MyValue";
}
```