public ActionResult GridViewPartialAddNew(MVC.Models.SampleModel item) { //var model = new object[0]; if (ModelState.IsValid) { try { // Insert here a code to insert the new item in your model SampleModelList.AddItem(item); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewPartial", SampleModelList.GetData())); }
public static void AddItem(SampleModel postedItem) { SampleModelList.GetData().Add(postedItem); }