首次發表,不太會寫,那點乾貨上個分,廢話不多說,不懂多看 1 public void Publist() 2 { 3 ResultListData resultData = new ResultListData(); 4 BLL.basic_project bllspro = new BLL.bas ...
首次發表,不太會寫,那點乾貨上個分,廢話不多說,不懂多看
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 }View Code