public ActionResult ModalWindow(AutoBrand brand, string mm) { if(brand is AutoBrand) { db.AutoBrands.Add(brand); db.SaveChanges(); } ViewBag.CurrenBrands = new SelectList(db.AutoBrands, "Id", "Name"); ViewBag.DDListAutoBrand = new SelectList(db.AutoBrands, "Id", "Name"); ViewBag.DDListAutoModel = new SelectList(db.AutoModels, "Id", "Name"); return PartialView("DDListAutoBrand"); }
public ActionResult DDListAutoBrand(AutoBrand br, AutoModel mdl) { AutoBrand sel = null; if(mdl is AutoModel) { sel = mdl.AutoBrand; } else if(br != null) sel = br; if(sel == null) sel = (from c in db.AutoBrands select c).ToList()[0]; ViewBag.DDListAutoBrand = new SelectList(db.AutoBrands, "Id", "Name", sel?.Id); ViewBag.DDListAutoModel = new SelectList(db.AutoModels.Where(tf => tf.AutoBrandID == sel.Id), "Id", "Name", mdl?.Id); return PartialView(); }