标签:var new tab app else ring pen table builder
DataTable dt=XXXX;
StringBuilder JsonStr = new StringBuilder();
if (dt.Rows.Count > 0)
{
JsonStr.Append("[");
for (int i = 0; i < dt.Rows.Count; i++)
{
JsonStr.Append("{");
for (int j = 0; j < dt.Columns.Count; j++)
{
if (j < dt.Columns.Count-1)
{
JsonStr.Append("\""+ dt.Columns[j].ColumnName.ToString() +"\":\"" + dt.Rows[i][j].ToString() + "\",");
}
else if (j == dt.Columns.Count-1)
{
JsonStr.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":\"" + dt.Rows[i][j].ToString() + "\"");
}
}
if (i == dt.Rows.Count - 1)
{
JsonStr.Append("}");
}
else
{
JsonStr.Append("},");
}
}
JsonStr.Append("]");
}
var value = JsonStr.ToString();
标签:var new tab app else ring pen table builder
原文地址:http://www.cnblogs.com/chj929555796/p/7147506.html