Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi to all! I'm new to mvc3 and i am creating the search module....
In my form i have two drop down list called state and district where district depend on selection of state....
I have created view model for state and district

C#
public class State_district
    {
       
       public int selectedDistrictid{get;set;}
        public IEnumerable<State> states { get; set; }
        public State stateid{ get; set; }
        public string selectedstate { get; set; }
        public IEnumerable<District> districts{get;set;}
        public District distId { get; set; }
       
    }

in the controller:

SQL
public ActionResult Index()
        {
            var model = new State_district { states = db.States, districts = from m in db.Districts select m };
            return View(model);
        }

and in the view , i am calling the dropdown using following:
C#
<div class="editor-field">*Select State:-
           @Html.DropDownListFor(x => x.states, new SelectList(Model.states, "Id", "State_Name"), new {id = "states"})

          </div>

I want to get value of selected state's id and district-id and depending on that i need to get result from my database table. so i need to pass this value to controller where other action link will help to find data from table

Can someone help me with this.....
Posted
Updated 8-Mar-12 5:04am
v2

1 solution

I think that jquery.cascadingDropDown.js will work for you. Check out this article on it.
http://weblogs.asp.net/rajbk/archive/2010/05/20/cascadingdropdown-jquery-plugin-for-asp-net-mvc.aspx
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900