Today, in this article, I will explain how to create a cascading dropdown list using MVC, Web API, and jQuery. Here, I am using three tables - Country, State, and City - respectively. If we select a country, then it should display country related states and when we select a state, it should display state-related cities. Finally, here, we will use MVC, Web, jQuery, and SQL Server. So now, let us see the required steps.
Step 1
We have to create three tables - Country, State, and City.

Step 2
Now, we need to create an MVC application but we will create two projects here - one is Web API project for the creation of service and the other one is MVC project for consuming that service. So now, let us add the first MVC project.
Open Visual Studio and go to File->New ->Web application ->select MVC ->OK.

Step 3
Now, add tables in web API project using Entity Framework. So for this, go to Models folder ->right-click -> Add -> New item -> ADO.NET Entity Data Model -> click Add -> select database first approach->click Next.
Select "New Connection" and give the connection details, then select database -> click OK.
Choose tables and click OK.

Step 4
Now, we will write the logic for binding the Country, State and City, So, I create a folder Business Logic and take a class CascadingLogic.cs and write the logic.

public class CascadingLogic
{
JobPortalEntities dbEntity = new JobPortalEntities();
public List<Country> BindCountry()
{
this.dbEntity.Configuration.ProxyCreationEnabled = false;
List<Country> lstCountry = new List<Country>();
try
{
lstCountry = dbEntity.Countries.ToList();
}
catch (Exception ex)
{
ex.ToString();
}
return lstCountry;
}
public List<State> BindState(int countryId)
{
List<State> lstState = new List<State>();
try
{
this.dbEntity.Configuration.ProxyCreationEnabled = false;
lstState = dbEntity.States.Where(a => a.CountryId == countryId).ToList();
}
catch (Exception ex)
{
ex.ToString();
}
return lstState;
}
public List<City> BindCity(int stateId)
{
List<City> lstCity = new List<City>();
try
{
this.dbEntity.Configuration.ProxyCreationEnabled = false;
lstCity = dbEntity.Cities.Where(a => a.StateId == stateId).ToList();
}
catch (Exception ex)
{
ex.ToString();
}
return lstCity;
}
}
After that, we will add an API Controller.

Now, create the API methods and call the methods one by one.
[RoutePrefix("api/Cascading")]
public class CascadingDetailsController : ApiController
{
CascadingLogic objCasc = new CascadingLogic();
[HttpGet]
[Route("CountryDetails")]
public List<Country> BindCountryDetails()
{
List<Country> countryDetail = new List<Country>();
try
{
countryDetail = objCasc.BindCountry();
}
catch (ApplicationException ex)
{
throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = ex.Message });
}
catch (Exception ex)
{
throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.BadGateway, ReasonPhrase = ex.Message });
}
return countryDetail;
}
[HttpGet]
[Route("StateDetails")]
public List<State> BindStateDetails(int CountryId)
{
List<State> stateDetail = new List<State>();
try
{
stateDetail = objCasc.BindState(CountryId);
}
catch (ApplicationException ex)
{
throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = ex.Message });
}
catch (Exception ex)
{
throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.BadGateway, ReasonPhrase = ex.Message });
}
return stateDetail;
}
[HttpGet]
[Route("CityDetails")]
public List<City> BindCityDetails(int stateId)
{
List<City> cityDetail = new List<City>();
try
{
cityDetail = objCasc.BindCity(stateId);
}
catch (ApplicationException ex)
{
throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = ex.Message });
}
catch (Exception ex)
{
throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.BadGateway, ReasonPhrase = ex.Message });
}
return cityDetail;
}
}
Step 5
Now, let's go in MVC project and add a Controller.








Dẫn Dương ĐìnhPosted Jun 20, 2025, 3:16 PM
In the tutorial clip about Cascading Dropdown List Of Country, State And City Using MVC, Web API And jQuery, I want to get the values ??in each dropdown List and save them to another Database Table, how can I do that?
Pranali PatilPosted Jan 24, 2024, 9:24 AM
Ajax call not working
alex smailPosted Aug 28, 2020, 9:05 AM
Like it. but do you know how to display all countries and city in the world?
Rohit MhatrePosted May 25, 2020, 5:41 AM
Follow the link for the answer: https://techstudy.org/mvc/populate-city-dropdown-based-on-state-dropdown
Mark TaborPosted Apr 5, 2019, 5:36 PM
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:58010/api/Cascading/CountryDetails shows resource cannot be found
Mark TaborPosted Apr 5, 2019, 5:20 PM
In MVC controller which action method i need to write and what they would return how the mapping is done between MVC controller and API controller
Mark TaborPosted Apr 5, 2019, 4:44 PM
I am new to web api , I have a question if we have already written the logic in businesslogic class then why we are again writing a method in web api and calling it from that class , if i can omit the business class and write the complete logic in API then what ?
Lae KhamPosted Apr 4, 2019, 12:08 AM
Wow, this is an excellent example and thank you very much for sharing. I am struggling how to pre-select City>State>Country or retrieving after saved to database. Here is what I am trying accomplish. I have another table call Employee that linked to "CityId" of City table, so when "Edit" button selected I would like to pre-select City>State>Country for update. Please help. Thank you very much in advance. Dek Lao
Abdul NasirPosted Sep 23, 2018, 11:08 AM
How can we load datagrid as wel another dropdwonlist with single click of a dropdownlist
Viknaraj ManogararajahPosted Aug 6, 2018, 6:55 PM
nice to thank you for sharing
Metehan MetinPosted Jun 26, 2018, 10:50 AM
How can I apply autocomplete to this dropdowns, would you please explain
Yadu YPosted Jun 13, 2018, 8:09 AM
How to get that data from dropdown box
Diba MadibaPosted Jun 5, 2018, 7:58 AM
Where is the source code for this? It's unreadable in the current state, thanks.
Richard KazimotoPosted May 31, 2018, 2:43 AM
Big up Kumar... You are such a genious... This was straight forward.. So amazing and superb. Worked just fine for me straight away
sumit singhPosted Apr 12, 2018, 2:31 AM
Please do it hurry up
sumit singhPosted Apr 11, 2018, 6:07 AM
Actually i want to know that how to insert data of dropdownlist ??
sumit singhPosted Apr 6, 2018, 8:50 AM
Can u please suggest me the post method code of this page??
Lakshman KPosted Mar 14, 2018, 7:09 PM
It is not working for me, as soon as the page initiates I see the alert popup written for Country dropdown in the cshtml file. I just followed the steps and not sure where exactly went wrong. Able to build with zero errors also, getting the UI page correctly. The issue is with the country list unable to retreive from database. I suspect the error with the URL in the AJAX call code. Please advise.
Naresh SinghalPosted Mar 12, 2018, 11:22 PM
Fantastic, awesome & mind blowing , a perfect article with MVC,API & Jquery....Liked it.....Its Sharply explained....