How can I return a Custom error for a Grid Operation.
E.g.: If the database delete is not possible show a popup that something is gone wrong.
Controller Method:
regards
E.g.: If the database delete is not possible show a popup that something is gone wrong.
Controller Method:
[HttpPost]
public ActionResult DestroyEmploymentStatus([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]List<
EmploymentStatusViewModel
> employmentStatuses)
{
if (employmentStatuses.Any())
{
foreach (var esvm in employmentStatuses)
{
var es = db.EmploymentStatuses.Find(esvm.Id);
db.EmploymentStatuses.Remove(es);
db.SaveChanges();
}
}
return Json(employmentStatuses.ToDataSourceResult(request, ModelState));
}
regards