I am using PagedList
to display paging on my search payment results page. I want to display only 5 payments on each page. The search criteria I am testing returns 15 records. I am expecting only 5 records on first page with page numbers 1,2,3 at bottom. I see the page numbers as expected at the bottom but all 15 records get displayed on every page. I have debugged the code and found out that StaticPagedList
function is returning 15 records instead of 5. My controller action code is as given below:
public ViewResult ViewPayment(int? billerId, int? billAccount, int? page)
{
var pageIndex = (page ?? 1) - 1;
var pageSize = 5;
List<Payment> paymentList = new List<Payment>();
paymentList = _paymentBusiness.GetPayments(billerId, billAccount);
var paymentsAsIPagedList = new StaticPagedList<Payment>(paymentList, pageIndex + 1, pageSize, paymentList.Count);
ViewBag.OnePageOfPayments = paymentsAsIPagedList;
return View(paymentList);
}
Please let me know if I have mistaken anything.