let's say I have 2 drop down's and one displays the States list and another Occupation. Both are independent in this scenario.
On the database side, I've a user profile record with fields that saves "state_code" and "Occupation_desc"
The table that saves the state details will have two fields: state_desciption, state_code The table that saves the state details will have two fields: Occupation_desc, id
When loading the profile, On binding the drop down control, I need to show the state name rather than the short-cut(I need to show California rather than "CA", but db record will have "CA".)
sample code:
drpdwnstates.DataSource = //binding the results
Me.drpdwnstates.DataTextField = "state_desciption"
Me.drpdwnstates.DataValueField = "state_code"
Me.drpdwnstates.DataBind()
For example, if i'm loading a user profile from California, then i need to highlight/select the California in my dropdown.
Contract to this, other drop down will have the Occupation list need to show the description itself(description itself is saved in the user profile record, not id).
Any help on how to select the saved value on the load??
You can select an item by setting the selected value of the DropDownList:
drpdwnstates.SelectedValue = "CA";
If the state code is saved in the user profile, you may set the value this way:
drpdwnstates.SelectedValue = userProfile.StateCode;
You can adapt this code to the specific data structure of your user profiles.