datatable 查询返回JSON

DataTable dt = costFO.GetQueryTable(projectid, date); var newrow = from x in dt.Rows.Cast().Where(C => C.Field("CostMonthReportItem_Type") != "") select new { type = x.Field("CostMonthReportItem_Type").ToString(), name = x.Field("CostMonthReportItem_PayNext").ToString() }; StringBuilder jsons = new StringBuilder(); JavaScriptSerializer jss = new JavaScriptSerializer(); Dictionary drow = new Dictionary(); newrow.ToList().ForEach(x => { drow.Add(x.type.ToString(), x.name.ToString()); }); context.Response.Write(jss.Serialize(drow));
把学习一种技术一直坚持下去。
原文地址:https://www.cnblogs.com/cxlings/p/2658324.html