DropDownList with some Categories loaded and i need to populate another @Html.DropDownList depending on the option selected on the 1st dropdown.
This is the code I use to populate the 1st dropdown:
On the Controller:
TecnicService ListCategory = new TecnicService();
IList<Category> resultCat = ListCategory.GetCategory();
List<SelectListItem> CatDropDown = new List<SelectListItem>();
foreach (Category in resultadoCat)
{
CatDropDown.Add(new SelectListItem
{
Value = a.Id.ToString(),
Text = a.Name.ToString()
});
}
On the View:
@model APP.Models.DataViewModel
@using (Html.BeginForm("NewPol", "Tecnic", null, FormMethod.Post, new { id = "pol-data-form", @class = "form-horizontal" }))
{
<div class="control-group">
<label for="category" class="control-label">Category</label>
<div class="controls">
@Html.DropDownList("BasicData", Model.Category, new { @class= "required", name="category"})
</div>
</div>
<div class="control-group">
<label for="ram" class="control-label">Ram</label>
<div class="controls">
@Html.DropDownList() WHAT DO I DO HERE???????
</div>
</div>
.
.}
I get the data through a service which returns a List, now I need to populate the 2nd dropdown depending on the selection of the 1st dropdown.