【发布时间】:2015-07-18 00:10:58
【问题描述】:
我正在尝试使用打包的PagedList.MVC 来尝试强制我的数据拆分为页面。但是,我在 controller 中走了这么远,然后收到上述错误,下面给出了另一个错误:
'PagedList.PagedList.PagedList(System.Collections.Generic.IEnumerable
, int, int)' 的最佳重载方法匹配有一些无效参数
但是,我认为一旦我的第一个错误得到解决,这个错误就会得到解决。
谁能帮我解决这个问题?
控制器:
public ActionResult SupplierReportSelection(int ClientID, int? SupplierID = null, int? ReviewPeriodID = null, int page = 1)
{
ClaimsBySupplierViewModel SupplierModel = ClaimsBySupplier(ClientID, SupplierID, ReviewPeriodID);
int pageSize = 10;
int pageNumber = (page);
PagedList<ClaimsBySupplierViewModel> model = new PagedList<ClaimsBySupplierViewModel>(SupplierModel, page, pageSize);
ViewBag.client = client;
return View("ClaimsBySupplier", model);
}
视图模型:
public class ClaimsBySupplierViewModel : ReportViewModel {
public IQueryable<ClaimsBySupplierReport> ReportData { get; set; }
public IQueryable<SupplierAndClaimNumberReviewTotalsByStatusCategory> ReportTotalData { get; set; }
public decimal? Conversion { get; set; }
}
【问题讨论】:
-
那么你到底想要“页面”什么呢?
ReportData还是ReportTotalData?PagedList仅“页面”一个集合,因此不清楚您打算在视图中显示什么。 -
抱歉,ReportData 和 ReportTotalData 都包含我的模型的集合。我只想将结果分成页面以减少加载时间
-
我已经更新了我的答案,您将模型作为一个整体引用,但需要指定哪个列表。
-
我刚刚在上次之前看到了您的评论,如果您希望两个列表都显示在同一页面上但作为分页列表,只需将列表与 Linq 或在您填充列表的存储库中合并.
-
我也不想这样做,我只想显示一个包含我的模型 ClaimsBySupplierModel 的 ClaimsBySupplierViewModel 列表。然后我想将此列表拆分为页面
标签: c# asp.net-mvc pagination