码迷,mamicode.com
首页 > 其他好文 > 详细

控制器内分页和显示

时间:2018-07-29 22:17:39      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:http   param   art   column   tab   bag   uid   list   and   

  public ActionResult Index()
        {
            return View(GetStudetPage());
        }
        [HttpPost]
        public ActionResult Index(string StuName, DateTime? StuKTime, DateTime? StuJTime)
        {
            string where = "1=1";
            if (StuName != null)
            {
                where += "and StuName like ‘%" + StuName + "%‘";
            }
            if (StuKTime != null)
            {
                where += " and StuKTime > ‘" + StuKTime + "‘";
            }
            if (StuJTime != null)
            {
                where += " and StuJTime <‘" + StuJTime + "‘";
            }
            Where = where;
            return PartialView("_PartialPage1", GetStudetPage());
        }
        static int PageSize = 3;
        static int PageIndex = 1;
        static string Where = "";
        public List<stuclass> GetStudetPage()
        {
            PageParams pargePar = new PageParams
            {
                TableName = "Student",
                IndexCol = "StuID",
                PageSize = PageSize,
                PageIndex = PageIndex - 1,
                OrderCol = "StuID asc",
                Where = Where,
                Columns = "*"
            };
            Pages<stuclass> pages = bl.GetStudetPage(pargePar);
            ViewBag.SumCount = pages.SumCount;
            ViewBag.SumPage = pages.SumCount;
            ViewBag.PageIndex = PageIndex;
            return pages.list;
        }
        [HttpPost]
        public ActionResult Page(int index)
        {
            PageIndex = index;
            return PartialView("_PartialPage1", GetStudetPage());
        }

控制器内分页和显示

标签:http   param   art   column   tab   bag   uid   list   and   

原文地址:https://www.cnblogs.com/fsl123/p/9387600.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!