I’m using an ASP.NET dropdown. I want to set the selected element using an ID (Id) which is stored in the DataValue field.
ddlTest.DataValueField = "Id";
ddlTest.DataTextField = "Name";
ddlTest.DataSource = searchResultList;
ddlTest.DataBind();
But all I can see is the SelectedIndex property which isn’t the correct thing. How do I set by value?
After it’s bound you can set the SelectedValue property to the correct id.