asp.net mvc 3 - how to use cascading dropdownlist in mvc -
am using asp.net mvc3, have 2 tables in want data dropdown based on dropdown has perform.for example if select country has show states belonging country,am using following code in controller.
viewbag.country= new selectlist(db.country, "id", "name", "--select--"); viewbag.state= new selectlist("", "stateid", "name"); @html.dropdownlistfor(model => model.country, (ienumerable<selectlistitem>)viewbag.country, "-select-") @html.dropdownlistfor(model => model.state, (ienumerable<selectlistitem>)viewbag.state, "-select-") but using able countries.
there jquery plugin can this...
you don't want refresh whole page everytime changes country drop down - ajax call update state drop down far more user-friendly.
Comments
Post a Comment