We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

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.



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); 
        } 



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 
 


Loader.
Live Chat Icon For mobile
Up arrow icon