Tag: pagedlist

PagedListPager传递其他模型数据

我有以下型号: public class PagedClientViewModel { public int? Page { get; set; } public PagedList.PagedList 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。 更改页面时如何保留复选框数据?

带有entity framework的PagedList获取所有记录

PagedList是一个Paging库。 _dbContext.Products.ToList().ToPagedList(1, 25); 上面的代码将在第1页的数据库中获得前25条记录。 问题是ToList()调用将获取数据库中的所有记录。 然后ToPageList()调用将选择前25个记录。 如何将EF与PagedList结合使用,以便只获取数据库中的前25条记录? 并没有获得所有记录,然后采取前25记录。 PS:我应该编写自己的Paging库还是使用在线库? 请推荐我任何其他图书馆。

PagedList和Async

我在我的视图中使用了PagedList,但我的脚手架控制器是使用这种默认的索引操作生成的: public async Task Index() { return View(await db.Claimants.ToListAsync()); } 我没有找到PagedList的扩展名来使用async 。 我的方法必须改为这样的forms: public ActionResult Index(int? page) { var claimants = db.Claimants.OrderBy(b => b.Name); var notNullPage = page ?? 1; return View(claimants.ToPagedList(notNullPage, 50)); } 是否有合理的方式使用PagedList和async ?

“IEnumerable ”类型在未引用的程序集中定义

我已将以下nuget包添加到我的MVC 5应用程序X.PagedList.Mvc中 我在控制器/视图中返回结果如下: // Repo public IPagedList GetPagedPosts(int pageNumber, int pageSize) { var posts = _context.Post .Include(x => x.Category) .Include(x => x.Type); // Return a paged list return posts.ToPagedList(pageNumber, pageSize); } // View model public class PostViewModel { public IPagedList Posts { get; set; } … } // Controller method public ActionResult Index(int? page) { […]

PagedList错误:必须在方法’Skip’之前调用方法’OrderBy’

这是完整的错误消息:方法’Skip’仅支持LINQ to Entities中的排序输入。 必须在方法’Skip’之前调用’OrderBy’方法 在“PurchaseOrderController”中,我已将此代码添加到索引方法中: // GET: PurchaseOrder public ActionResult Index(int? page) { return View(db.PurchaseOrders.ToPagedList(page ?? 1, 3)); } 同样在“PurchaseOrders”的索引视图中,我添加了以下代码: @using PagedList; @using PagedList.Mvc; @model IPagedList @{ ViewBag.Title = “Index”; } Index @Html.ActionLink(“Create New”, “Create”) @Html.DisplayNameFor(model => model.First().PurchaseRequest_) @Html.DisplayNameFor(model => model.First().Date) @Html.DisplayNameFor(model => model.First().Requestor) @Html.DisplayNameFor(model => model.First().Vendor) @Html.DisplayNameFor(model => model.First().DateOrdered) @Html.DisplayNameFor(model => model.First().ConfirmedWith) @Html.DisplayNameFor(model => […]

在局部视图中使用分页,asp.net mvc

如果有人可以提供以下建议,我将不胜感激:在我的视图中,我显示了项目列表: @model PagedList.IPagedList @using PagedList.Mvc; @foreach (var item in Model) {//displaying data} 我的寻呼机看起来像这样: @Html.PagedListPager(Model, page => Url.Action(“Index”, new { humanID = ViewBag.HumanID, page = page }), new PagedListRenderOptions { LinkToFirstPageFormat = “<>”, }) 问题是当我点击下一页时,它返回空白,没有我的_Layout 。 我不想一直重装_Layout。 有没有办法使用Ajax.ActionLink的寻呼机? 这样我可以在部分视图中UpdateTargedId ?

将PagedList与ViewModel ASP.Net MVC一起使用

我正在尝试在我的ASP.Net应用程序中使用PagedList,我在微软网站上找到了这个例子http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting -filtering-和寻呼与-的entity frameworkfunction于一个-ASP净MVC-应用 在使用ViewModel的复杂情况下如何使用PagedList? 我试图在没有成功的情况下将PagedList添加到此处发布的教师示例中: http : //www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/reading-related-data-with -the-entity frameworkfunction于一个-ASP净MVC-应用 问题是ViewModel由类而不是简单字段组成,因此我无法使用ToPageList()方法转换结果。 这是ViewModel结构: using System.Collections.Generic; using ContosoUniversity.Models; namespace ContosoUniversity.ViewModels { public class InstructorIndexData { public IEnumerable Instructors { get; set; } public IEnumerable Courses { get; set; } public IEnumerable Enrollments { get; set; } } } 我需要将三个表连接到ViewModel并在View中显示结果。

如何在Asp.net MVC和entity framework中进行分页时应用filter?

我有一个使用ASP.NET MVC框架编写的Web应用程序。 在我的Homecontroller我有一个名为Index的动作,它响应Get请求。 在此操作中,我使用IPagedList库创建页面以将记录分成多个页面。 我的Index@HttpGet看起来像这样 public ActionResult Index(int? id) { using(var connection = new Context()) { int pageNumber = (id ?? 1); var presenter = new Presenter { Presenter = pageNumber, Tasks = connection.Tasks.ToPagedList(pageNumber, 30), Form = new TasksFiltersViewModel() } return View(presenter); } } 我还有一个名为Index的操作,它响应Post请求,该请求应用了一些filter。 所以在Post请求中我做了这样的事情 [HttpPost] [ValidateAntiForgeryToken] public ActionResult Index(Presenter model) { int pageNumber […]