PagedListPager传递其他模型数据

PagedListPager传递其他模型数据

本文介绍了PagedListPager传递其他模型数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下模型:

  public class PagedClientViewModel
    {
        public int? Page { get; set; }
        public PagedList.PagedList<ClientViewModel> Clients { get; set; }
        public bool ShowAllClients { get; set; }
    }

ShowAllClients是一个复选框,我将使用它进一步过滤从服务器返回的客户端列表.

ShowAllClients is a checkbox that I'll use to further filter the list of clients returned from the server.

 @Html.CheckBoxFor(model => model.ShowAllClients, new { id = "ShowAllClientsCheckbox" })

这是我的寻呼机:

@Html.PagedListPager(Model.Clients, page => Url.Action("Index", new { Page = page }), PagedListRenderOptions.DefaultPlusFirstAndLast)

寻呼机和复选框都在同一表格上.

Both the pager and checkbox are on the same form.

我遇到的问题是,当我更改寻呼机控件上的页面时,该复选框始终设置为false.发生这种情况是因为在Index操作中,ShowAllClients设置为false.

The problem that I'm having is that when I change page on the pager control, the checkbox is always set to false. This is happening because in the Index action, ShowAllClients is set to false.

更改页面时如何保存复选框数据?

How would I preserve the checkbox data when changing pages?

推荐答案

我将其与以下内容一起使用:

I got this to work with the following:

 @Html.PagedListPager(Model.Clients, page => Url.Action("Index", new PagedClientViewModel { Page = page, ShowAllClients = Model.ShowAllClients }))

这篇关于PagedListPager传递其他模型数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 07:20