public ActionResult Index(int?page)
        {
            StudentListModel model = new StudentListModel();

            var list = StudentBiz.GetAll();

            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);

            bindList(model);

            return(View(model));
        }
Exemple #2
0
        void bind(MyTestModel model)
        {
            model.Select1 = StudentBiz.GetAll().Select(s => new SelectListItem
            {
                Value = s.Sn.ToString(),
                Text  = s.Name
            });

            model.Select2 = StudentBiz.GetAll().Select(s => new SelectListItem
            {
                Value = s.Sn.ToString(),
                Text  = s.Name
            });

            //班級
            model.ClassSelect = ClassMBiz.GetAll().Select(s => new SelectListItem
            {
                Value = s.Id.ToString(),
                Text  = s.Name
            });

            if (!string.IsNullOrWhiteSpace(model.ClassId))
            {
                var list = StudentBiz.ClassData(model.ClassId).Select(s => new SelectListItem
                {
                    Value = s.Sn.ToString(),
                    Text  = s.Name
                });

                model.StudentSelect = list;
            }
            else
            {
                model.StudentSelect = new List <SelectListItem>();
            }
        }
Exemple #3
0
 // GET api/default1
 public IEnumerable <StudentInfo> Get()
 {
     return(StudentBiz.GetAll());
 }