public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //得到实例化的所有的信息 List <Model.HKSJ_Employees> employees = employeesService.GetModelList(string.Empty); //得到总的数量 int total = employeesService.GetRecordCount(string.Empty); //{ // "total":239, // "rows":[ // {"code":"001","name":"Name 1","addr":"Address 11","col4":"col4 data"}, // ] //} //实例化成前台需要的Json var date = new { total = total, rows = employees }; //将此实例化集合进行转换成Json对象, JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); string data = javaScriptSerializer.Serialize(date); //输出所有的信息 context.Response.Write(data); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //加载信息 BLL.HKSJ_Employees employees = new BLL.HKSJ_Employees(); //Empoyees = employees.GetModelList(string.Empty); //分页 int pageIndex = Request["pageIndex"] == null ? 1 : Convert.ToInt32(Request["pageIndex"]); int pageSize = Request["pageSize"] == null ? 10 : Convert.ToInt32(Request["pageSize"]); int totalCount = employees.GetRecordCount(string.Empty); Empoyees = employees.DataTableToList(employees.GetListByPage(string.Empty, "id", (pageIndex - 1) * pageSize + 1, pageSize * pageIndex).Tables[0]); NavPager = Common.LaomaPager.ShowPageNavigate(pageSize, pageIndex, totalCount); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //判断用户是否登录 if (context.Session["user"] == null) { context.Response.Write("请您正常操作"); return; } //得到实例化的所有的信息 //List<Model.HKSJ_Employees> employees = bll.GetModelList(string.Empty); //将信息构造成前台分页的信息 //page:1,rows:20 int pageIndex = context.Request["page"] == null ? 1 : Convert.ToInt32(context.Request["page"]); int pageSize = context.Request["rows"] == null ? 10 : Convert.ToInt32(context.Request["rows"]); //得到表中de总的数量 int total = bll.GetRecordCount(string.Empty); List <Model.HKSJ_Employees> list = bll.GetPageNavEmployees(pageIndex, pageSize, out total); //{ // "total":239, // "rows":[ // {"code":"001","name":"Name 1","addr":"Address 11","col4":"col4 data"}, // ] //} //实例化成前台需要的Json var date = new { total = total, rows = list }; //将此实例化集合进行转换成Json对象, JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); string data = javaScriptSerializer.Serialize(date); //输出所有的信息 context.Response.Write(data); }