C# PagedListPager传递其他型号数据
我有以下型号:C# PagedListPager传递其他型号数据,c#,asp.net-mvc,pagedlist,C#,Asp.net Mvc,Pagedlist,我有以下型号: public class PagedClientViewModel { public int? Page { get; set; } public PagedList.PagedList<ClientViewModel> Clients { get; set; } public bool ShowAllClients { get; set; } } 这是我的传呼机: @
public class PagedClientViewModel
{
public int? Page { get; set; }
public PagedList.PagedList<ClientViewModel> Clients { get; set; }
public bool ShowAllClients { get; set; }
}
这是我的传呼机:
@Html.PagedListPager(Model.Clients, page => Url.Action("Index", new { Page = page }), PagedListRenderOptions.DefaultPlusFirstAndLast)
寻呼机和复选框位于同一窗体上
我遇到的问题是,当我在寻呼机控件上更改页面时,复选框总是设置为false。这是因为在索引操作中,ShowAllClients设置为false
如何在更改页面时保留复选框数据?我得到了以下信息:
@Html.PagedListPager(Model.Clients, page => Url.Action("Index", new PagedClientViewModel { Page = page, ShowAllClients = Model.ShowAllClients }))
到目前为止,最好的解决方案是:
@Html.PagedListPager(Model.Clients, page => Url.Action("Index", new { Page = page, param1="",param2="" }), PagedListRenderOptions.DefaultPlusFirstAndLast)
是的,它可以工作。在我的例子中,模型是PagedList.IPagedList。接下来,我使用了一个“SearchModel”,我将它存储在ViewBag中,这样就可以很容易地传递它。我只需要更新页码
@Html.PagedListPager(Model, page =>
{
ViewBag.SearchModel.Page = page;
return Url.Action("Index", "Search", ViewBag.SearchModel);
})
感谢您快速简便的解决方案。
@Html.PagedListPager(Model, page =>
{
ViewBag.SearchModel.Page = page;
return Url.Action("Index", "Search", ViewBag.SearchModel);
})