Problem when posting data from View to controller (Update)

Hi I am using MySql with Entity Framework and am having issue with posting Updated Data from the Grid back to controller update ActionResult

I am using VS2017 and asp.net MVC 5 application with latest version of Syncfusion and Entity Framework

The reurned data fro an update are null


@{
ViewBag.Title = "Home Page";
}

Here



@(Html.EJ().Grid("Editing")
.Datasource(ds => ds.Json((IEnumerable)ViewBag.datasource).UpdateURL("/Test/Update")
.InsertURL("/Test/Insert").RemoveURL("/Test/Remove").Adaptor(AdaptorType.RemoteSaveAdaptor))
.AllowSorting()

.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.AllowPaging()
.Columns(col =>
{
col.Field("CarTrackID").HeaderText("ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(90).Add();
col.Field("CarTrackClientName").HeaderText("Client Name").TextAlign(TextAlign.Right).Width(90).Add();
col.Field("CarTrackEmail").HeaderText("Email").TextAlign(TextAlign.Right).Width(80).Add();
}))

public class TestController : Controller
{
// GET: Test
public ActionResult Index()
{
var dma = new Car();

dma.Configuration.ProxyCreationEnabled = false;

var result = dma.cartracks.ToList();

ViewBag.datasource = result.ToList();

return View();
}

public ActionResult Update(cartrack hm)
{
return null;
}
}


Thanks in advance

Edmund Herbert

1 Reply

MS Mani Sankar Durai Syncfusion Team November 15, 2017 12:41 PM UTC

Hi Edmund, 

Thanks for contacting Syncfusion support. 

We have checked your query and we are not able to reproduce the reported issue. We have also prepared a sample in grid with latest version by performing CRUD operation that can be downloaded from the below link 
Refer the code example 
@(Html.EJ().Grid<object>("Editing") 
        .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource).Adaptor(AdaptorType.RemoteSaveAdaptor).UpdateURL("/Home/Update").InsertURL("/Home/Insert").RemoveURL("/Home/Remove")) 
        ... 
        .AllowPaging() 
        .Columns(col => 
        { 
... 
        }) 
 
) 
 
 
public ActionResult Update(Order value) 
        { 
             
                db.Entry(value).State = EntityState.Modified; 
                db.SaveChangesAsync(); 
                
                return Json(value, JsonRequestBehavior.AllowGet); 
            
        } 
        public ActionResult Insert(Order value) 
        { 
            db.Orders.Add(value); 
            db.SaveChanges(); 
            var data = db.Orders.ToList(); 
            
            return Json(data, JsonRequestBehavior.AllowGet); 
        } 
        public ActionResult Remove(int key) 
        { 
            Order order = db.Orders.Find(key); 
            db.Orders.Remove(order); 
            db.SaveChanges(); 
            return Json(order, JsonRequestBehavior.AllowGet);  
        } 
 

Refer the screenshot below 
 

If you still face the issue please get back to us with the following details. 
1.       Share the screenshot/ video of the issue that you have faced. 
2.       Share the full grid code and controller page. 
3.       If possible please reproduce the issue in the above attached sample. 
The provided information will help us to analyze the issue and provide you the response as early as possible. 

Regards, 
Manisankar Durai. 


Loader.
Up arrow icon