首次发表,不太会写,那点干货上个分,废话不多说,不懂多看
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 public void Publist() 2 { 3 ResultListData resultData = new ResultListData(); 4 BLL.basic_project bllspro = new BLL.basic_project(); 5 6 int pageIndex = string.IsNullOrEmpty(context.Request["page"]) ? 1 : Convert.ToInt32(context.Request["page"]); 7 int pageSize = string.IsNullOrEmpty(context.Request["limit"]) ? 10 : Convert.ToInt32(context.Request["limit"]); 8 9 var strWhere = " is_del=0"; 10 DataSet ds = bllspro.GetListByPage(strWhere, "", pageIndex * pageSize - pageSize + 1, pageIndex * pageSize); 11 12 DataTable table = new DataTable(); 创建DataTable 13 14 table.Columns.Add("autoid", typeof(string)); 为DataTable添加列 15 table.Columns.Add("pub_id", typeof(string)); //typeof(string)为数据类型 16 table.Columns.Add("pub_name", typeof(string)); 17 table.Columns.Add("pub_version", typeof(string)); 18 table.Columns.Add("pub_data", typeof(string)); 19 table.Columns.Add("pub_state", typeof(string)); 20 21 foreach (DataRow dr in ds.Tables[0].Rows) 22 { 23 DataRow row = table.NewRow(); 24 row[0] = dr["autoid"]; 25 row[1] = dr["project_id"]; 26 row[2] = dr["project_name"]; 27 row[3] = "2020.7.1.1.0";//版本这里随便加的数据 28 row[4] = dr["add_time"];//日期 29 row[5] = dr["project_state"]; 30 table.Rows.Add(row); 31 } 32 33 ds.Reset(); //清除DataSet 34 ds.Tables.Add(table); //将表添加到DataSet中 35 var count = ds.Tables[0].Rows.Count; //获取行数 36 37 resultData.code = 0; 38 resultData.msg = "获取数据成功!"; 39 resultData.data = table; 40 resultData.count = count; 41 var json = JsonHelper.ToJsonTime(resultData); 42 context.Response.Write(json); 43 }