// GET: Admin/ContactType public ActionResult Index(int?id) { object storedId = (id.HasValue) ? id : (TempData["ContactTypeList.Index"] != null) ? TempData["ContactTypeList.Index"] : null; int parentId = Convert.ToInt32(storedId); var model = db.ContactTypes.Where(w => (w.ParentId == parentId)).OrderBy(ob => ob.Name).ToList(); TempData["ContactTypeList.Index"] = storedId; ViewBag.contactSelected = ContactType.DropDown(parentId); if (Request.IsAjaxRequest()) { return(PartialView("_Index", model)); } return(View(model)); }