Assuming the list is already data bound, you can simply set the SelectedValue property in the drop-down list.
list.DataSource = GetListItems(); // <-- Get your data from somewhere. list.DataValueField = "ValueProperty"; list.DataTextField = "TextProperty"; list.DataBind(); list.SelectedValue = myValue.ToString();
The value of the myValue variable must exist in the property specified in the DataValueField in the data binding of the controls.
UPDATE : If the value myValue does not exist as a value with drop-down options, the first option in the drop-down list will be selected by default.
Wallace Breza Aug 16 '10 at 19:17 2010-08-16 19:17
source share