Код: Выделить всё
public ActionResult HistoryView()
{
var model = new TemplateViewModel();
model.Depts = _uow.Repository().GetAll();
ViewBag.listCompanies = new SelectList(_uow.Repository().GetAll(),"DeptID","Dept_Name");
return View(model);
}
public JsonResult GetStores( int DeptID)
{
TemplateViewModel templateViewModel = new TemplateViewModel
{
Dept = _uow.Repository().Get(x => x.DeptID == DeptID),
Templates = _uow.Repository().GetAll().ToList()
};
return Json(templateViewModel, JsonRequestBehavior.AllowGet);
}
Код: Выделить всё
Select your Company:[/b][b]
@Html.DropDownList("DeptID", (IEnumerable)ViewBag.listCompanies,String.Empty, new {style = "width: 200px;"})
Select Store[/b]
@Html.DropDownList("TemplateID", new SelectList(string.Empty, "Value", "Text"), "--Select Store--", new { style = "width:200px;" } )
$(document).ready(function() {
$("#DeptID").change(function() {
$("TemplateID").empty();
$.getJSON('/HistoryLog/getstores', { DeptID: $('#DeptID').val() }, function(data) {
$.each(data, function () {
$('#TemplateID').append('' + this.Text + '');
});
});
});
});



Подробнее здесь: https://stackoverflow.com/questions/790 ... e-serve-re