Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET drop-down MVC3
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
 
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:
 
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:
  <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 8-Mar-12 0:06am
Edited 8-Mar-12 5:04am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 26 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100