private string DataTableTojson(DataTable dt)
{
List> list=new List>();
foreach (DataRow rows in dt.Rows)
{
Dictionary dict = new Dictionary();
foreach (DataColumn col in dt.Columns)
{
dict[col.ColumnName] = rows[col];
}
list.Add(dict);
}
JavaScriptSerializer jss = new JavaScriptSerializer();
return jss.Serialize(list);
}
推荐博文:http://www.cnblogs.com/starksoft/p/3944088.html