Example #1
0
        public ActionResult Index()
        {
            var model = new StudentListModel();
            var list  = StudentBiz.QueryData(" ", " ");

            int currentPageIndex = 0;

            model.List = new MvcPaging.PagedList <StudentInfo>(list, currentPageIndex, 2);

            bindList(model);

            return(View(model));
        }
Example #2
0
        public ActionResult Index(StudentListModel model, string sortCol, bool?sortDesc, int?page)
        {
            model.Name    = string.IsNullOrWhiteSpace(model.Name) ? "" : model.Name;
            model.ClassId = string.IsNullOrWhiteSpace(model.ClassId) ? "" : model.ClassId;
            var list = StudentBiz.QueryData(model.ClassId, model.Name);

            if (!string.IsNullOrWhiteSpace(sortCol))
            {
                ListSort <StudentInfo> .GetList(list, sortCol, sortDesc.Value);
            }

            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            int pageSize         = 2;

            while (currentPageIndex > 0 &&
                   list.Count <= currentPageIndex * pageSize)
            {
                currentPageIndex--;
            }

            model.List = new MvcPaging.PagedList <StudentInfo>(list, currentPageIndex, pageSize);

            return(PartialView("List", model.List));
        }