public ActionResult History(string searchString, string currentFilter, int?page) { if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; var disbursements = string.IsNullOrEmpty(searchString) ? _disbursementRepo.GetAll().OrderByDescending(d => d.CollectionDate).ToList() : _disbursementRepo.GetDisbursementsByDeptName(searchString).ToList(); var disHistory = disbursements.ToPagedList(pageNumber: page ?? 1, pageSize: 15); if (Request.IsAjaxRequest()) { return(PartialView("_History", disHistory)); } return(View(disHistory)); }