I have a grid that when it tries to update, the ID field of my model is an empty guid when it gets back to the controller. I am displaying the column in the guid and the value is definitely there. What would cause the ID to be stripped out like that?
Here is my view with the grid:
And here is the UpdateBrand method from the BrandMaintenance controller:
I have several other grids that were created the exact same way and they are all working, so I am wondering what I could possibly be missing that could cause this.
Thanks for any help!
Here is my view with the grid:
@model List<
Common.Models.Brand
>
@{
ViewBag.Title = "Maintain Brands";
}
<
h2
>Maintain Brands</
h2
>
@(Html.Kendo().Grid(Model)
.Name("MaintainBrandsGrid")
.Columns(columns =>
{
columns.Bound(brand => brand.BrandId).Title("Id");
columns.Bound(brand => brand.BrandName).Title("Brand Name");
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(185);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable(scr=>scr.Height(430))
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.ServerOperation(false)
.Model( model => model.Id( brand => brand.BrandId))
.Create( create => create.Action("AddBrand", "BrandMaintenance"))
.Update( update => update.Action("UpdateBrand", "BrandMaintenance"))
.Destroy( delete => delete.Action("RemoveBrand", "BrandMaintenance"))
)
)
And here is the UpdateBrand method from the BrandMaintenance controller:
//
// POST: /BrandMaintenance/UpdateBrand
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult UpdateBrand([DataSourceRequest]
DataSourceRequest request, Brand brand)
{
if
(brand !=
null
&& ModelState.IsValid)
{
var bll =
new
CatalogMaintenanceBll();
bll.UpdateBrand(brand);
}
return
Json(
new
[] { brand }.ToDataSourceResult(request, ModelState));
}
I have several other grids that were created the exact same way and they are all working, so I am wondering what I could possibly be missing that could cause this.
Thanks for any help!