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));

你可能感兴趣的:(Datatable)