Main FAQ Category: Controls (14)
How to programmatically select a value in DropDownList Control in ASP.NET?
Posted: 20-Apr-2008
Updated: 20-Apr-2008
Views: 40752

I know this FAQ sounds ridiculous and that the answer is pretty obvious but i have discovered that not all beginner ASP.NET developers know that SelectedValue property of DropDownList control can be used not only to retrieve the value of the item that is currently selected but also to set the selected item of the DropDownList.

So for those of you which did not know this, If you have a (amongst other) item in your control with value "3", this line of code will make that item selected in your DropDownList control:

        DropDownList1.SelectedValue = "3";