// GET: USER/KhoaHoc public ActionResult Index(string searchString, int?page, string age, string PriceSort, string AgeSort) { var dao = new KhoaHocModel(); var model = dao.GetCOURSEs(); //page if (searchString != null && page <= 1) { page = 1; } if (PriceSort != null && page <= 1) { page = 1; } if (AgeSort != null && page <= 1) { page = 1; } ViewBag.AgeSort = AgeSort; ViewBag.PriceSort = PriceSort; ViewBag.searchString = searchString; if (!string.IsNullOrEmpty(searchString)) { model = dao.SearchCOURSEs(searchString); } if (!string.IsNullOrEmpty(PriceSort)) { model = dao.FilterCOURSEsByPrice(PriceSort); } if (!string.IsNullOrEmpty(AgeSort)) { model = dao.FilterCOURSEsByAge(AgeSort); } int pageSize = 9; int pageNumber = (page ?? 1); return(View(model.ToPagedList(pageNumber, pageSize))); //return View(model); }