You know the County that was selected previously, so you can also establish which state the county is in. You populate the State dropdownlist with all states, and ensure that the one that the chosen county is in is selected:
var items = statelist.Select(s => new SelectListItem {
Value = s.StateAbbrev,
Text = s.StateName,
Selected = s.StateAbbrev == <selected state> ? true : false
});
Equally, you prepopulate the county dropdown with the selected value in the same way. If the user wants to change the selection, your jquery will do its thing of the user wants to choose from another state.
Mikesdotnett...
All-Star
154818 Points
19853 Posts
Moderator
MVP
Re: Setting values in jQuery cascading drop-down on Update page.
May 07, 2012 06:54 PM|LINK
You know the County that was selected previously, so you can also establish which state the county is in. You populate the State dropdownlist with all states, and ensure that the one that the chosen county is in is selected:
var items = statelist.Select(s => new SelectListItem { Value = s.StateAbbrev, Text = s.StateName, Selected = s.StateAbbrev == <selected state> ? true : false });Equally, you prepopulate the county dropdown with the selected value in the same way. If the user wants to change the selection, your jquery will do its thing of the user wants to choose from another state.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter