Wednesday, May 23, 2007

Selecting Items on Populated DropDownList

DropDownList1.SelectedValue = dr["type"].ToString();
// Value you have given as "value" once you populate combo

- OR -

DropDownList1.Items.FindByValue(dr["id"].ToString()).Selected = true;
//Search for the value on the list, then select it

- OR -

DropDownList1.Items.FindByText(dr["desc"].ToString()).Selected = true;
//Search for the text on the list, then select it

No comments: