Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# PagedListPager传递其他型号数据_C#_Asp.net Mvc_Pagedlist - Fatal编程技术网

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);
})