Exemplo n.º 1
0
        public string BindSource(int pagesize, int page, string sqlwhere)
        {
            BBS.BLL.BBSTopic bll = new BBS.BLL.BBSTopic();
            //获取分页数据
            DataSet ds = bll.GetListByPage(sqlwhere, "", pagesize * page + 1, pagesize * (page + 1));  //获取数据源的ds会吧。

            ds.Tables[0].TableName = "List";
            return(Web.DataConvertJson.DataTable2Json(ds.Tables[0]));
        }
Exemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string json   = "{}";
            string action = context.Request.Form["Action"];

            int uid = int.Parse(context.Request["UID"]);

            int    displayStart  = int.Parse(context.Request["offset"]); //起始页
            int    displayLength = int.Parse(context.Request["limit"]);  //每页数量
            string strwhere      = "";

            if (uid != 0)
            {
                strwhere = "tuid=" + uid;
            }

            BBS.BLL.BBSTopic bll = new BBS.BLL.BBSTopic();
            int     total        = bll.GetRecordCount(strwhere);
            DataSet ds           = bll.GetListByPage(strwhere, "", displayStart + 1, displayStart + displayLength);

            ds.Tables[0].TableName = "rows";
            //返回列表
            json = Web.DataConvertJson.DataTable2Json(ds.Tables[0]);

            //??服务器端返回的数据中还要包括rows,total(数据总量)两个字段,前端要根据这两个字段分页。
            json = "{\"total\":" + total + "," + json.Substring(1);

            /*
             * 返回数据格式
             * {"total":100,"rows":....}
             *
             */

            context.Response.Write(json);
        }