Reputation: 143
I have a list of countries, which returns an ID and a Name. I also have a string. The drop down sets the value to the ID, but at this point I don't have the ID's. I want to be able to set the selectedvalue as the Text Field. Is there a way to do this? or is there a way to compare my string against the list to work out the ID?
string country = "Australia";
ddlCountry.DataSource = listofcountries;
ddlCountry.DataTextField = "Value";
ddlCountry.DataValueField = "Key";
ddlCountry.DataBind();
ddlCounty.SelectedValue = ???
Thanks
Upvotes: 0
Views: 1113