C# – How to set a dropdownlist item as selected in ASP.NET

asp.netc

I want to set selecteditem for asp. net dropdownlist control programmatically.

So I want to pass a value to the dropdownlist control to set the selected item where is the value of the item equal to the passed value.

Best Answer

dropdownlist.ClearSelection(); //making sure the previous selection has been cleared
dropdownlist.Items.FindByValue(value).Selected = true;