This question is locked. New answers and comments are not allowed.
Hello,
I've setup an Ajax enabled MVC grid. Inserting and deleting records work ok, updating doesn't. I use TryUpdateModel as suggested in the demo, but for some reason that returns:
"Value cannot be null.\r\nParameter name: entity"
The weird thing is that I also use TryUpdateModel on insert, and then it works fine. So I'm not sure what goes wrong on update or what I could do to find out. As a workaround, I'm now updating directly from the FormCollection parameter, but since that's hardcoded I'd rather use TryUpdateModel instead.
Here's the grid code:
And the controller code:
I've setup an Ajax enabled MVC grid. Inserting and deleting records work ok, updating doesn't. I use TryUpdateModel as suggested in the demo, but for some reason that returns:
"Value cannot be null.\r\nParameter name: entity"
The weird thing is that I also use TryUpdateModel on insert, and then it works fine. So I'm not sure what goes wrong on update or what I could do to find out. As a workaround, I'm now updating directly from the FormCollection parameter, but since that's hardcoded I'd rather use TryUpdateModel instead.
Here's the grid code:
<%= Html.Telerik().Grid<ApplicationCategory>()
.Name("Grid")
.DataKeys(keys =>
{
keys.Add(c => c.ApplicationCategoryId);
})
.ToolBar(commands =>
{
commands.Insert();
})
.DataBinding(dataBinding =>
{
dataBinding.Ajax()
.Select("SelectApplicationCategories", "Admin")
.Insert("InsertApplicationCategory", "Admin")
.Update("UpdateApplicationCategory", "Admin")
.Delete("DeleteApplicationCategory", "Admin");
})
.Columns(columns =>
{
columns.Bound(c => c.Name).Width(360);
columns.Command(commands =>
{
commands.Edit();
commands.Delete();
}).Width(200);
})
.Editable(editing => editing.Mode(GridEditMode.InLine))
%>
And the controller code:
[Authorize(Roles = "Admin")]
[GridAction]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateApplicationCategory(Guid id, FormCollection form)
{
ApplicationCategory category = adminRepository.GetApplicationCategory(id);
TryUpdateModel(category);
adminRepository.Save();
//Rebind the grid
return View(new GridModel(adminRepository.GetApplicationCategories()));
}