MVC posting IPagedList

六眼飞鱼酱① 提交于 2019-11-28 12:37:06

Work around for this problem is to pass the paging meta data as separate property and reconstruct the IPagedList in the view. Like below

public class PagedClientViewModel
{
    public int? Page { get; set; }
    public List<ClientViewModel> Clients { get; set; }
    public IPagedList PagingMetaData { get; set; } 
}

gererating th metadata

pagedClientViewModel.PagingMetaData = new StaticPagedList<ClientViewModel>(pagedClientViewModel.Clients, pageIndex, pageSize, TotalClients).GetMetaData();

constructing the pager in the view

<div style="text-align: center">
    @Html.PagedListPager(new StaticPagedList<ClientViewModel>(Model.Clients, Model.PagingMetaData), page => Url.Action("<actionname>", new { page }), PagedListRenderOptions.Classic)
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!