- Home
- Forum
- ASP.NET MVC
- Strange edit/update behavior!
Strange edit/update behavior!
I have a grid that I fill and update using the following code. The strange issue is that when I edit/update a row one time, everything works. But if I attempt to edit/update a row twice in one session I get a 500 error on the browser. If I try to update another row in the same session it works, but again if I go back and try to edit/update that row again I get the 500 error. It seem like I can only update a specific row once per session, if I try to edit/update a row twice I get the 500 error... Not sure why everything works on the first edit, but not the second....
It seems very row specific. I can edit/update every row per session, but I cannot edit/update the same row twice per session...
View
@(Html.EJ().Grid<Request>("OneCloudGrid").Datasource(ds => ds.Json(Model.Requests).UpdateURL (@Url.Action("Update","OneCloud")).InsertURL (@Url.Action("Insert","OneCloud")).RemoveURL(@Url.Action("Remove", "OneCloud")).Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowEditing(); })
........
Controller
public ActionResult OneCloud() //replaces index
{
RequestClassView Rmodel = new ViewModels.RequestClassView();
Rmodel.Requests = db.Requests.ToList();
return View(Rmodel);
}
public ActionResult Update(Request value)
{
Request req = db.Requests.Single(o => o.RequestID == value.RequestID);
db.Entry(req).CurrentValues.SetValues(value);
db.Entry(req).State = EntityState.Modified;
req.Updated = DateTime.Now;
req.UpdatedBy = ((AuthUser)Session["user"]).Name;
db.SaveChanges();
var result = db.Requests.ToList();
return Json(new { result = result, count = result.Count }, JsonRequestBehavior.AllowGet);
}
Error I get after the second+ update request on an specific row.

It seems very row specific. I can edit/update every row per session, but I cannot edit/update the same row twice per session...
View
@(Html.EJ().Grid<Request>("OneCloudGrid").Datasource(ds => ds.Json(Model.Requests).UpdateURL (@Url.Action("Update","OneCloud")).InsertURL (@Url.Action("Insert","OneCloud")).RemoveURL(@Url.Action("Remove", "OneCloud")).Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowEditing(); })
........
Controller
public ActionResult OneCloud() //replaces index
{
RequestClassView Rmodel = new ViewModels.RequestClassView();
Rmodel.Requests = db.Requests.ToList();
return View(Rmodel);
}
public ActionResult Update(Request value)
{
Request req = db.Requests.Single(o => o.RequestID == value.RequestID);
db.Entry(req).CurrentValues.SetValues(value);
db.Entry(req).State = EntityState.Modified;
req.Updated = DateTime.Now;
req.UpdatedBy = ((AuthUser)Session["user"]).Name;
db.SaveChanges();
var result = db.Requests.ToList();
return Json(new { result = result, count = result.Count }, JsonRequestBehavior.AllowGet);
}
Error I get after the second+ update request on an specific row.
SIGN IN To post a reply.
1 Reply
PK
Prasanna Kumar Viswanathan
Syncfusion Team
December 8, 2016 11:31 AM UTC
Hi Micheal,
Thanks for contacting Syncfusion support.
We checked in our sample with Entity Framework and we able to edit and update the row twice in our sample.
Find the code example and sample:
| @(Html.EJ().Grid<object>("Grid") .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).UpdateURL("/Home/Update").InsertURL("/Home/Insert").RemoveURL("/Home/Delete").Adaptor(AdaptorType.RemoteSaveAdaptor)) -------------------------------------- .Columns(column => { ------------------------ })) -------------------------------------------------------------- public ActionResult Update(Employee value) { simpledbEntities1 context = new simpledbEntities1(); Employee table = context.Employees.Single(v => v.EmployeeID == value.EmployeeID); context.Entry(table).CurrentValues.SetValues(value); context.Entry(table).State = EntityState.Modified; context.SaveChanges(); return Json(value, JsonRequestBehavior.AllowGet); } |
Sample: https://www.syncfusion.com/downloads/support/forum/127767/ze/Grid-RemoteSaveAdaptor-1238003895
To find out root cause of the issue, we need the following details.
1. Code example of a Grid.
2. Video demonstration of an issue.
3. If you face any exception in server-side while updating the record for the second time, please share the screenshot of an exception.
4. Share the stackrace of an issue.
5. Essential Studio Version details.
6. If possible, replicate the issue in the attached sample.
Note: In your code example, we found that you return the result and count pair in the update method. It is not necessary to return the result and count pair in the update method. We can return the value in the update method.
Regards,
Prasanna Kumar N.S.V
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
ML Michael Lambert
- Dec 7, 2016 09:49 PM UTC
- Dec 8, 2016 11:31 AM UTC