When publishing collections, you must index them correctly. To do this, you should use a for foreach instead of foreach .
Also, why does your HttpPost accept String[] and not your model? First change this type of your model.
Assuming your model is: @model List<YourType>
Modify HttpPost to accept the following:
[HttpPost] public ActionResult Enviar(List<YourType> model) { ..... return View(); }
Now we will rewrite your foreach in for and use the CheckBoxFor helper. In addition, add HiddenFor fields for any properties that you want to see in the message:
@for (int i = 0; i < Model.Count; i++) { <tr> <td> @Html.CheckBoxFor(m => m[i].CELULAR) </td> <td name="Nome"> @Html.HiddenFor(m => m[i].NOME) @Html.DisplayFor(m => m[i].NOME) </td> <td name="Email"> @Html.HiddenFor(m => m[i].CANCELADO) @Html.DisplayFor(m => m[i].CANCELADO) </td> <td name="Celular" value="@m[i].CELULAR"> @Html.DisplayFor(m => m[i].CELULAR) </td> </tr> }
source share