Hi Llewelyn,
Thanks for contacting Syncfusion support.
We have analyzed your query and we have prepared a sample based on your requirement.
Please find the sample in the below attached link,
In this sample, ModelState.isValid has been worked based on its validation we passed for the particular column in grid. For example when CustomerID column should not exceeded the stringLength of 5. If it exceeded ModelState.isValid will be false else it will be true.
Please refer the below code example,
[HomeController.cs] public class Orders { … [Range(0, int.MaxValue, ErrorMessage = "OrderID must be greater than 0.")] public long OrderID { get; set; } [StringLength(5, ErrorMessage = "CustomerID must be 5 characters.")] public string CustomerID { get; set; } [StringLength(15, ErrorMessage = "ShipName must be 15 characters.")] public string ShipCity { get; set; } } public ActionResult Update([FromBody]CRUDModel<Orders> myObject) { if (ModelState.IsValid) { var ord = myObject.Value; … return Json(myObject.Value); } if (!ModelState.IsValid) { … return new StatusCodeResult(0); } return View(); } |
Also please refer the below screenshot about ModelState.isValid is working
Screenshot1: When ModelState.isValid is true.
Screenshot1: When ModelState.isValid is false.
Also we have displayed the error message in alert box using ActionFailure event in grid. ActionFailure event triggered for every grid action server failure event.
Please let us know if you need further assistance.
Regards,
Manisankar Durai.