Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model List<ElencoCertificazioniItem>
- ...
- @using (Html.BeginForm())
- {
- @Html.AntiForgeryToken()
- ...
- <tbody>
- @{
- for (int i = 0; i < Model.Count; i++)
- {
- <tr>
- <td>@Html.LabelFor(m => Model[i].Id) </td>
- <td>@Html.LabelFor(m => Model[i].description)</td>
- <td>@Html.EditorFor(m => Model[i].Field1.Value)</td>
- <td>@Html.EditorFor(m => Model[i].Field2.Value)</td>
- </tr>
- }
- }
- </tbody>
- }
- ....
- [HttpPost]
- [ValidateAntiForgeryToken]
- [HttpParamAction]
- public ActionResult SaveItems(List<ElencoCertificazioniItem> model)
- {
- //the items here is null!!! ;(
- return saveItems(model);
- }
- public class ElencoCertificazioniItem
- {
- public int Id { get; set; }
- public string description { get; set; }
- public bool? Field1 { get; set; }
- public bool? Field2 { get; set; }
- }
- public class HttpParamActionAttribute : ActionNameSelectorAttribute
- {
- public override bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo)
- {
- if (actionName.Equals(methodInfo.Name, StringComparison.InvariantCultureIgnoreCase))
- return true;
- var request = controllerContext.RequestContext.HttpContext.Request;
- return request[methodInfo.Name] != null;
- }
- }
- <tr>
- <td>
- @Html.LabelFor(m => Model[i].Id)
- @Html.HiddenFor(m => Model[i].Id)
- </td>
- <td>
- @Html.LabelFor(m => Model[i].description)
- @Html.HiddenFor(m => Model[i].description)
- </td>
- <td>@Html.EditorFor(m => Model[i].Field1)</td>
- <td>@Html.EditorFor(m => Model[i].Field2)</td>
- </tr>
Add Comment
Please, Sign In to add comment