The point is that the following model is passed to the view:
public class IndexViewModel { public IEnumerable<OrderViewModel> Orders { get; set; } public PageInfo PageInfo { get; set; } }
In the view itself, the Orders collection is displayed in the foreach
construction:
@using (Html.BeginForm("OrdersAction", "Admin", FormMethod.Post)) { .......... @foreach (var o in Model.Orders) { <tr> <td>@Html.CheckBoxFor(m => o.Selected)</td> <td>@Html.TextBoxFor(m => o.Id)</td> <td>@Html.TextBoxFor(m => o.UserName)</td> .......... </tr> } <button name="action" value="confirm">Подтвердить</button><br> <button name="action" value="cancel">Отменить</button><br> ..... <div class="btn-group"> @Html.PageLinks(Model.PageInfo, x => Url.Action("Orders", new { page = x })) </div> }
The view uses pagination (helper @Html.PageLinks()
), if that matters. I can not figure out how to get in the controller collection Orders
.