我有以下型号:
public class PagedClientViewModel
{
public int? Page { get; set; }
public PagedList.PagedList<ClientViewModel> Clients { get; set; }
public bool ShowAllClients { get; set; }
}
ShowAllClients是一个复选框,我将用它来进一步过滤从服务器返回的客户端列表。
@Html.CheckBoxFor(model => model.ShowAllClients, new { id = "ShowAllClientsCheckbox" })
这是我的寻呼机:
@Html.PagedListPager(Model.Clients, page => Url.Action("Index", new { Page = page }), PagedListRenderOptions.DefaultPlusFirstAndLast)
寻呼机和复选框都在同一表格上。
我遇到的问题是,当我在寻呼机控件上更改页面时,复选框始终设置为false。发生这种情况是因为在Index操作中,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)
是的,它的确有效。