public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //判断用户是否登录 if (context.Session["user"] == null) { context.Response.Write("请您正常操作"); return; } //取出新闻列表 BLL.HKSJ_Main mainService = new BLL.HKSJ_Main(); //获取分页的参数 int pageIndex = context.Request["page"] == null ? 1 : int.Parse(context.Request["page"]); int pageSize = context.Request["rows"] == null ? 10 : int.Parse(context.Request["rows"]); //计算出总数量 int totalCount = mainService.GetRecordCount(string.Empty); var newsList = mainService.GetNavPageData(pageSize, pageIndex, out totalCount); //将得到的数据转换成json格式字符串 var data = new { total = totalCount, rows = newsList }; JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); string json = javaScriptSerializer.Serialize(data); context.Response.Write(json); }
protected void Page_Load(object sender, EventArgs e) { BLL.HKSJ_Main mainBLL = new BLL.HKSJ_Main(); #region 无分页获取数据 ////获取数据 //NewsList = mainBLL.GetModelList(string.Empty); #endregion #region 分页获取数据 int totalListCount = mainBLL.GetRecordCount(string.Empty); //注意为空处理 int pageIndex = int.Parse(Context.Request["pageIndex"] ?? "1"); //每页显示的数量 int pageSize = 5; //获得要前端要显示的页数连接的数量,注意totalListCount数量过小处理 pageCount = Math.Max((totalListCount + pageSize - 1) / pageSize, 1); #region 代码生成器做法 //DataSet set = mainBLL.GetListByPage(string.Empty, "id", (pageIndex - 1) * pageSize + 1, pageIndex * pageSize); //NewsList = mainBLL.DataTableToList(set.Tables[0]); #endregion #region 自行编写存储过程及其对应三层代码做法 NewsList = mainBLL.MyGetListByPage(pageSize, pageIndex, out totalListCount); #endregion //处理链接导航栏,用一个静态类 PageNav = Pager.ShowPageNavigate(pageSize, pageIndex, totalListCount); #endregion }
protected void Page_Load(object sender, EventArgs e) { //输出所有的信息 BLL.HKSJ_Main mainService = new BLL.HKSJ_Main(); //mainShowo = mainService.GetModelList(string.Empty); //分页每页显示13个记录 int pageIndex = Request["pageIndex"] == null ? 1 : Convert.ToInt32(Request["pageIndex"]); int pageSize = Request["pageSize"] == null ? 13 : Convert.ToInt32(Request["pageSize"]); //获取总数totalCount int totalCount = mainService.GetRecordCount(string.Empty); DataSet ds = mainService.GetListByPage(string.Empty, "ID", pageSize * (pageIndex - 1) + 1, pageSize * pageIndex); mainShowo = mainService.DataTableToList(ds.Tables[0]); NavPager = Common.LaomaPager.ShowPageNavigate(pageSize, pageIndex, totalCount); }
protected void Page_Load(object sender, EventArgs e) { //获取网站Main表中的数据 BLL.HKSJ_Main mainServices = new BLL.HKSJ_Main(); // mainShow = mainServices.GetModelList(string.Empty); //首先获取分页参数 int pageSize = Request["pageSize"] == null ? 10 : Convert.ToInt32(Request["pageSize"]); int pageIndex = Request["pageIndex"] == null ? 1 : Convert.ToInt32(Request["pageIndex"]); //获取到totalCount的数据 int totalCount = mainServices.GetRecordCount(string.Empty); //计算在页面上面显示的分页的数量 DataSet ds = mainServices.GetListByPage(string.Empty, "ID", pageSize * (pageIndex - 1) + 1, pageIndex * pageSize); mainShow = mainServices.DataTableToList(ds.Tables[0]); NavPager = Common.LaomaPager.ShowPageNavigate(pageSize, pageIndex, totalCount); }