Cascading DropDownList in ASP.Net MVC

This sample shows how to implement cascading drop down lists in ASP.Net MVC.  The user is presented with a list of countries. Once a country is selected, a new drop down list is displayed with the states in the selected country.After selecting the Country, the State Drop Down Lis

C# (1.8 MB)
4.9 Star
17,554 times
Add to favorites
E-mail Twitter Digg Facebook
Sign in to ask a question

  • Jquery error
    2 Posts | Last post June 16, 2014
    • Hi,
      I found that the line 
      var URL = $("#CountryStateFormID").data("stateListAction");
      fails in jquery-1.8.2 and also 2.2.1, i haven't tested any versions or found why this happens. In your downloadable code it's using version 1.5.1 and it's working fine.
      It gets an Undefined because it seems not to find the stateListAction data attribute.
      Instead I found I can use .attr("data-stateListAction") to make it work.
    • I ran into this same problem using jquery-1.7.1; within countryState.js, by using .attr("data-stateListAction"); instead of .data("stateListAction"); it worked great for me. Thanks for having posted this! You saved my day.
  • About cascading ddl as filter of table of data
    1 Posts | Last post June 26, 2013
    • Hi Rick,
      I have two things in my view 'ListUrl.cshtml' a dropdown list filled with the names of URLs. and list (html Table) where 'URLs' as the first column. I want that the data in the table depends on the change in ddl selection.
      how can I achieve something like this.
      apologize because I am new to MVC, I have always worked with webforms.
      Thank you.
  • About cascading
    1 Posts | Last post February 21, 2013
    • Hello Rick.I want to ask you something.It seems that my js file is working but it doesn't  seem that when the url is generated from the json the actionresult is never called.I ve checked names and so forth!
      Thank you.
  • About cascading DDL in MVC
    1 Posts | Last post August 20, 2012
    • Hello i am using recursive Database table for category.
      tbl_category(ID,name, parentID).
      I want to implement Cascading DropDownList that can load as many dropdownlist for category that have multiple hierarchy of subcategories. 
      How to do using ASP.NET MVC ? any Hint.
      I am not using entity framework and razor view.
      I have made object class of database table.
      Himen Suthar
  • Importing Project Into VS2008
    2 Posts | Last post February 16, 2012
    • Hi Rick,
      I'm trying to import your solution into VS2008 to see how it works and I noticed right from the beginning that the views are .cshtml whereas in VS2008, the views are .aspx.  What's the difference between the two formats and is there some way to convert cshtml to aspx?  
    • .aspx uses the Web Forms view engine and .aspx uses the razor view engine. You can still use the razor views, most of the important information is in the JavaScript. VS2008 doesn't work with razor, but the development server will (or you could use IIS 7.5 if you have Win7)