public void ProcessRequest(HttpContext context) { //Url取参方式 HttpRequest request = context.Request; HttpResponse response = context.Response; //response.ContentType = "text/plain"; string _search = request["_search"]; string numberOfRows = request["rows"]; string pageIndex = request["page"]; string sortColumnName = request["sidx"]; string sortOrderBy = request["sord"]; string pars = request["pars"]; string json = new StreamReader(request.InputStream).ReadToEnd(); JavaScriptSerializer js = new JavaScriptSerializer(); QueryConfig m = null; if (!string.IsNullOrEmpty(pars)) { m = js.Deserialize<QueryConfig>(pars); } try { List<ChinaUser> dataSourcelist = new List<ChinaUser>() { new ChinaUser() { ID=1,UserName="******",CreateTime=Convert.ToDateTime("2016/7/13")}, new ChinaUser() { ID=2,UserName="******",CreateTime=Convert.ToDateTime("2016/7/13")}, new ChinaUser() { ID=3,UserName="******",CreateTime=Convert.ToDateTime("2016/7/13")}, new ChinaUser() { ID=4,UserName="******",CreateTime=Convert.ToDateTime("2016/7/13")}, new ChinaUser() { ID=5,UserName="******",CreateTime=Convert.ToDateTime("2016/7/13")}, new ChinaUser() { ID=6,UserName="******",CreateTime=Convert.ToDateTime("2016/7/13")} }; List<ChinaUser> dataList = dataSourcelist; if (m != null && m.ID != null) { dataList = dataSourcelist.Where(a => a.ID == m.ID).ToList(); } dataList=QueryByPage(Convert.ToInt32(numberOfRows), Convert.ToInt32(pageIndex), dataList).ToList(); GridData model = new GridData(); model.page = pageIndex; model.records = Convert.ToString(dataSourcelist.Count);//总行数 model.total = "2";//算出总页数 model.rows = dataList; JavaScriptSerializer serializer = new JavaScriptSerializer(); string Resul = serializer.Serialize(model); context.Response.Write(Resul); } catch (Exception ex) { //throw ex; } }
public void ProcessRequest(HttpContext context) { //Url取参方式 HttpRequest request = context.Request; HttpResponse response = context.Response; //response.ContentType = "text/plain"; string _search = request["_search"]; string numberOfRows = request["rows"]; string pageIndex = request["page"]; string sortColumnName = request["sidx"]; string sortOrderBy = request["sord"]; string pars = request["pars"]; string json = new StreamReader(request.InputStream).ReadToEnd(); JavaScriptSerializer js = new JavaScriptSerializer(); QueryConfig m = null; if (!string.IsNullOrEmpty(pars)) { m = js.Deserialize <QueryConfig>(pars); } try { List <ChinaUser> dataSourcelist = new List <ChinaUser>() { new ChinaUser() { ID = 1, UserName = "******", CreateTime = Convert.ToDateTime("2016/7/13") }, new ChinaUser() { ID = 2, UserName = "******", CreateTime = Convert.ToDateTime("2016/7/13") }, new ChinaUser() { ID = 3, UserName = "******", CreateTime = Convert.ToDateTime("2016/7/13") }, new ChinaUser() { ID = 4, UserName = "******", CreateTime = Convert.ToDateTime("2016/7/13") }, new ChinaUser() { ID = 5, UserName = "******", CreateTime = Convert.ToDateTime("2016/7/13") }, new ChinaUser() { ID = 6, UserName = "******", CreateTime = Convert.ToDateTime("2016/7/13") } }; List <ChinaUser> dataList = dataSourcelist; if (m != null && m.ID != null) { dataList = dataSourcelist.Where(a => a.ID == m.ID).ToList(); } dataList = QueryByPage(Convert.ToInt32(numberOfRows), Convert.ToInt32(pageIndex), dataList).ToList(); GridData model = new GridData(); model.page = pageIndex; model.records = Convert.ToString(dataSourcelist.Count); //总行数 model.total = "2"; //算出总页数 model.rows = dataList; JavaScriptSerializer serializer = new JavaScriptSerializer(); string Resul = serializer.Serialize(model); context.Response.Write(Resul); } catch (Exception ex) { //throw ex; } }