public ActionResult Category(int page = 1) { Session["ControllerName"] = "Category"; if (Session["loginDetails"] != null) { int pageSize = 10; int totalPage = 0; int totalRecord = 0; List<Category> category = new List<BLL.Category>(); ProductAdminBLL bll = new ProductAdminBLL(); totalRecord = bll.GetCategoryForPagination().Count(); totalPage = (totalRecord / pageSize) + ((totalRecord % pageSize) > 0 ? 1 : 0); category = bll.GetCategoryForPagination().OrderBy(a => a.Cat_Name).Skip(((page - 1) * pageSize)).Take(pageSize).ToList(); ViewBag.TotalRows = totalRecord; ViewBag.PageSize = pageSize; return View(category); } else { return RedirectToAction("Error"); } }