jquery.pagination实现分页查询功能

资源下载

1)前台代码

@{
    Layout = null;
}





    
    Index
    
    
    
    


    
学生编号 学生姓名
后台用linq实现分页查询

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace WebApplication62.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
        [HttpGet]
        public JsonResult GetStudents(int pageIndex, int pageSize)
        {
            JsonResult returnJson = new JsonResult();
            using (StudentClassDataContext scdc = new StudentClassDataContext())
            {
                List items = scdc.StudentDemo.Where(u => u.StudentName.Contains("学生"))
                                            .OrderByDescending(u => u.StudentID)
                                            .Take(pageIndex * pageSize)
                                            .Skip((pageIndex - 1) * pageSize)
                                            .ToList();
                int count = scdc.StudentDemo.Count();
                returnJson = Json(new
                {
                    Data = items,
                    Count = count
                }, JsonRequestBehavior.AllowGet);
            }
            return returnJson;
        }
    }
}



你可能感兴趣的:(jquery,pagination,分页,jquery)