I have a Index view calling a partial view where I list my model (an IEnumerable) and draw checkboxes to select some of the items to update.
I wrapped the partial view with a ajax form, to send the model (with the checked check boxes), but when it reach to the controller action "Enviar", the custom object parameter comes null
I don't know why, according some posts my code should be working, please, what I'm doing wrong?
Index View
@model IEnumerable<beDGRAIC.T_Sedd_Cuadro_Envio_Empresa>
.....
@Html.Partial("_ListaResumenCarga", Model)
.....
_ListaResumenCarga View
@model IEnumerable<beDGRAIC.T_Sedd_Cuadro_Envio_EmpresaViewModel>
@using (Ajax.BeginForm("Enviar", "Upload", new { @id = "FormCabecera" },
new System.Web.Mvc.Ajax.AjaxOptions()
{
HttpMethod = "POST",
InsertionMode = System.Web.Mvc.Ajax.InsertionMode.Replace,
UpdateTargetId = "SeccionListado",
OnSuccess = "RefrescaListado"
}))
{
<table>
<tbody>
@if (Model != null)
{
foreach (var item in Model)
{
<tr>
<td class="text-center">@Html.EditorFor(modelItem => item.Seleccionado, new { @checked = "checked" })</td>
<td class="text-left">@Html.DisplayFor(modelItem => item.Categoria)</td>
<td class="text-left">@Html.DisplayFor(modelItem => item.Codigo)</td>
<td class="text-left">@Html.DisplayFor(modelItem => item.Nombre)</td>
<td class="text-center">@Html.DisplayFor(modelItem => item.Nro_Registros)</td>
</tr>
@Html.HiddenFor(modelItem => item.Seleccionado)
@Html.HiddenFor(modelItem => item.Id_Cuadro_Envio)
}
}
</tbody>
</table>
<button type="submit">Enviar</button>
}
UploadController
public class UploadController : Controller
{
[HttpPost]
public ActionResult Enviar(IEnumerable<T_Sedd_Cuadro_Envio_EmpresaViewModel> lT_Sedd_Cuadro_Envio_EmpresaViewModel)
{
....
return View("Envios", vT_Sedd_Envio_Empresa);
}
}
Model Class
[DataContract]
[Serializable]
public partial class T_Sedd_Cuadro_Envio_EmpresaViewModel : BEPaginacion
{
[DataMember]
public bool Id { get; set; }
[DataMember]
public bool Seleccionado { get; set; }
[DataMember]
public int Id_Cuadro_Envio { get; set; }
[DataMember]
public int Id_Envio_Empresa { get; set; }
[DataMember]
public string Categoria { get; set; }
.... // more properties
}