public ActionResult GridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] SISESTAD.Model.clsModelInventarioSemillas item) { var model = new object[0]; if (ModelState.IsValid) { try { // Insert here a code to insert the new item in your model } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewPartial", model)); }
public ActionResult GridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] SISESTAD.Model.clsModelInventarioSemillas item) { var model = new object[0]; try { if ((item.Id != 0)) { List <clsModelInventarioSemillas> datos = new List <clsModelInventarioSemillas>(); datos.Add(item); IRestResponse taskSet = Task.Run(() => objServicio.fnEjecutarPostObject("IS/Actualizar", datos)).Result; switch (taskSet.StatusCode) { case System.Net.HttpStatusCode.OK: Session["strUltMensajeController"] = ""; break; case System.Net.HttpStatusCode.NotFound: Session["strUltMensajeController"] = "Error al consumir API"; ModelState.AddModelError("Error", "Error al consumir API."); break; default: Session["strUltMensajeController"] = "Error al conectarse a la base de datos " + taskSet.Content.ToString(); ModelState.AddModelError("Error", "Error al conectarse a la base de datos"); break; } } } catch (Exception e) { ViewData["EditError"] = e.Message; } //recuperar los datos del grid //return PartialView("_GridViewPartial", model); return(RedirectToAction("Index")); }