public ActionResult Index() { int pageIndex = Request["pageIndex"] == null ? 1 : int.Parse(Request["pageIndex"]); int pageSize = 10; int pageCount = newInfoService.GetPageCount(pageSize); pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > pageCount ? pageCount : pageIndex; List <NewInfo> list = newInfoService.GetPageList(pageIndex, pageSize);//获取分页数据 ViewData["list"] = list; ViewData["pageIndex"] = pageIndex; ViewData["pageCount"] = pageCount; return(View()); }
public ActionResult Index() { int pageIndex = Request["pageIndex"] != null?int.Parse(Request["pageIndex"]) : 1; int pageSize = 5; int pageCount = newInfoService.GetPagecount(pageSize);//得到页数 pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > pageCount ? pageCount : pageIndex; List <NewInfo> list = newInfoService.GetPageList(pageIndex, pageSize); ViewData["list"] = list; ViewBag.PageIndex = pageIndex; ViewBag.PageCount = pageCount; return(View()); }
public ActionResult Index() { int pageIndex = Request["pageIndex"] != null?int.Parse(Request["pageIndex"]) : 1; int pageSize = 5; int pageCount = newInfoService.GetPagecount(pageSize); pageIndex = pageIndex < 1 ? 1 : pageIndex; //判断页码是否小于1 pageIndex = pageIndex > pageCount ? pageCount : pageIndex; //判断页码是否大于总的页数 List <NewInfo> list = newInfoService.GetPageList(pageIndex, pageSize); //获取分页数据 ViewData["list"] = list; //用viewData可以将页面的数据传入到后台 ViewData["pageindex"] = pageIndex; ViewData["pagecoune"] = pageCount; return(View()); }