Is it possible to use cascading dropdownlist in ASP.Net MVC scaffolding? If yes, how?
I have here some of the codes that will show the dropdownlist using scaffolding:
MyController.cs
// GET: /ManualEntries/Create
public ActionResult Create()
{
ViewBag.cluscd = new SelectList(db.CLUSTERs, "clus_id", "clusdesc");
ViewBag.seccd = new SelectList(db.SECTORs, "sec_id", "secdesc");
return View();
}
Create.cshtml
<div class="form-group">
@Html.LabelFor(model => model.sec_id, "Sector", new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("sec_id", String.Empty)
@Html.ValidationMessageFor(model => model.sec_id)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.clus_id, "Cluster", new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("clus_id", String.Empty)
@Html.ValidationMessageFor(model => model.clus_id)
</div>
</div>