The following is my code for Updating. I have a custom view model that is a combination of 2 sql tables. The updates are processed successfully, but the dirty bit red triangle does not disappear. I have other grids in my solution that are bound directly to a specific sql table and those grids work as expected, the dirty bit disappears on successful updates to the database. What can I do in order to get the dirty bit cleared for my custom view?
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Update([DataSourceRequest]DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<
MenuProjectView
> menuprojectviews)
{
try
{
if (menuprojectviews != null && ModelState.IsValid)
{
foreach (var menuprojectview in menuprojectviews)
{
WorxMenus menu = db.WorxMenus.SingleOrDefault(s => s.Id == menuprojectview.MenuId);
menu.Title = menuprojectview.Title;
menu.Ordering = menuprojectview.Ordering;
menu.Date_Modified = DateTime.UtcNow;
Project project = db.Projects.SingleOrDefault(s => s.Id == menuprojectview.ProjectId);
project.ProjectType = (int)ProjectTypes.Schema;
project.SchemaName = menuprojectview.Title;
project.Date_Modified = DateTime.UtcNow;
db.SubmitChanges();
}
}
return Json(new[] { menuprojectviews }.ToDataSourceResult(request, ModelState));
}
catch (Exception e1)
{
ModelState.AddModelError("", e1.Message);
return Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet);
}
}