public ActionResult GridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] TEntity item) { var model = _dbSet; if (ModelState.IsValid) { try { model.Add(item); _db.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } ViewBag.ControllerName = _className; return(PartialView("_GridViewPartial", model.ToList())); }
public ActionResult GridViewDemoPartialAddNew(Category item) { var model = db.Categories; if (ModelState.IsValid) { try { model.Add(item); db.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewDemoPartial", model.ToList())); }