Hi,
How to implement Cascading DropDownList using jQuery in ASP.Net MVC
I have 2 dropdown base upon country i am population State value
this is what i have implemented from my side
could you please help me
@model report.Models.CascadingModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@Html.DropDownListFor(m => m.CountryId, Model.Countries, "Please select", new { onchange="GetStaeValue(this)" })
<br />
<br />
@Html.DropDownListFor(m => m.StateId, Model.States, "Please select", new { disabled = "disabled" })
</body>
</html>
public ActionResult Index()
{
CascadingModel model = new CascadingModel();
foreach (var country in entities.Countries)
{
model.Countries.Add(new SelectListItem { Text = country.CountryName, Value = country.CountryId.ToString() });
}
return View(model);
}
public class CascadingModel
{
public CascadingModel()
{
this.Countries = new List<SelectListItem>();
}
public List<SelectListItem> Countries { get; set; }
public int CountryId { get; set; }
public int StateId { get; set; }