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));
posted @ 2012-08-27 11:58  (二少)在南极  阅读(552)  评论(0编辑  收藏  举报