标签:
//将datatable转化为json
public string DataTableToJSON(DataTable dt)
{
JavaScriptSerializer jss = new JavaScriptSerializer();
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
foreach (DataRow dr in dt.Rows)
{
Dictionary<string, object> result = new Dictionary<string, object>();
foreach (DataColumn dc in dt.Columns)
{
result.Add(dc.ColumnName, dr[dc].ToString());
}
list.Add(result);
}
return jss.Serialize(list);
}
标签:
原文地址:http://www.cnblogs.com/whwfwfy/p/4597775.html