I have a partial view like this:
@model InventoryControl.Models.InventoryControlModel
<table class="table_body" style="font-size:x-small">
@if (Model != null)
{
for (var rolcnt = 0; rolcnt < Model.Roles.Count(); rolcnt ++)
{
<tr>
<td>
@Html.DisplayTextFor(x => x.Roles[rolcnt].ItemTypeCode)
</td>
<td>
@Html.CheckBoxFor(x=>x.Roles[rolcnt].Included)
</td>
</tr>
}
}
else
{
<span><i>User has no records for Inventory Control</i></span>
}
The partial view is populating correctly with the particular item type code and the included flag. I then try to post changes back with this:
function AddInventoryRole() {
$.ajax({
type: 'POST',
data: $("#InventoryRoleForm").serializeArray(),
url: '@Url.Action("PostInventoryRoles")',
success: function () {
alert('success');
},
error: function () {
alert('error');
}
});
}
I am seeing some of the data in the controller method. The item type code is not there, it's NULL for every entry, even the though the included flag is correct in the post. What am I doing wrong?
[HttpPost]
public ActionResult PostInventoryRoles(InventoryControlModel model)
{
return Json(model);
}