Reputation: 2251
I am trying to use the packaged PagedList.MVC
to try and force my data into splitting into pages. However I get so far in the controller and then receive the above error and another error is given below:
The best overloaded method match for 'PagedList.PagedList.PagedList(System.Collections.Generic.IEnumerable<ViewModel>, int, int)' has some invalid arguments
But, I think this error will be fixed once my first error is solved.
Can anybody help me with the problem?
Controller:
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);
}
ViewModel:
public class ClaimsBySupplierViewModel : ReportViewModel {
public IQueryable<ClaimsBySupplierReport> ReportData { get; set; }
public IQueryable<SupplierAndClaimNumberReviewTotalsByStatusCategory> ReportTotalData { get; set; }
public decimal? Conversion { get; set; }
}
Upvotes: 0
Views: 1167
Reputation: 892
The PagedList is looking for an IEnumerable object, such as a List of objects.
Being that your SupplierModel looks specific to one object with properties, that is what is causing your issue.
After seeing your Model's code, what you will want to do is reference your model's List of data you want to show, not just your model itself.
And instead of instantiating a PagedList object, return the view with the List of your data.
return View("ClaimsBySupplier", SupplierModel.ReportData.ToPagedList(page, pageSize);
Upvotes: 2