Cascading Dropdown in Mvc3

I am using Mvc3 I have 2 dropdown,BankBranch and city. On first time load of view i am binding both the dropdon without cascading. then if user select city i want to change bankbranch according to that. I am confused how i can achieve both the things together.

Thanks in advance.


This blog post should get you on your way. It provides examples for normal form posts, microsoft ajax form post, jquery ajax and others.

EDIT: Generalized Code Explanation


public class CascadeModel {
    public SelectList<City> Cities { get; set; }
    public SelectList<BankBranch> BankBranches { get; set;}
    public int CityId { get; set; }
    public int BranchId { get; set; }

public class Branch {
    public int Id { get; set;}
    public string Name { get; set; }


public ActionResult BranchSelector() {
     var viewData = new CascadeModel();
     viewData.Cities = new SelectList(Repository.GetAllCities(), "Id", "Name", selectedCity);
     viewData.BankBranches = new SelectList(Repository.GetBranchesByCity(selectedCity), "Id", "Name", "");
     return View(viewData);

public JsonResult GetBranches(int id) {
    return Json(Repository.GetBranchesByCity(id), JsonRequestBehavior.AllowGet);


@model CascadeModel

@Html.DropDownListFor(m => m.CityId, Model.Cities, new { style = "width:250px" })
<br />
@Html.DropDownListFor(m => m.BranchId, Model.BankBranches, new { style = "width:250px" })

<script type="text/javascript">
    $(document).ready(function() {
         $("#CityId").bind('change', function() {
                 url: '/Controller/GetBranches/' + $(this).val(),
                 success: function(data) {
                     //Clear the current branch ddl
                     //Load the new Branch data returned from the jquery call in the branches ddl

Need Your Help

Migrating Oracle 10g Enterprise to AWS RDS oracle 12c

oracle amazon-web-services migration rds

I have been assigned to move 10g database to AWS Oracle 12c. Size of data is around 20 GB of actual data but 900 GB has been allocated. So we will need to decrease that. Any suggestions on how to

Can't make MovieClip in function dissapear

function actionscript-3 actionscript movieclip enterframeevent

I'm trying to make simple shooting game with Fiat Multipla falling up to bottom of the screen. I have created function to generate falling multipla and within this function I have a problem.