private static string GetTasksString(int TaskId, DataTable dt)
{
DataRow[] rows = dt.Select("ParentID=" + TaskId.ToString());
if (rows.Length == 0) return string.Empty; ;
StringBuilder str = new StringBuilder();
foreach (DataRow row in rows)
{
str.Append("{");
for (int i = 0; i < row.Table.Columns.Count; i++)
{
if (i != 0) str.Append(",");
str.Append(""" + row.Table.Columns[i].ColumnName + """);
str.Append(":"");
str.Append(row[i].ToString());
str.Append(""");
}
//if (GetTasksString((int)row["menuid"], dt) != "")
//{
str.Append(","menus":[");
//}
str.Append(GetTasksString((int)row["menuid"], dt));
//if (GetTasksString((int)row["menuid"], dt) != "")
//{
str.Append("]");
//}
str.Append("},");
}
return str[str.Length - 1] == ',' ? str.ToString(0, str.Length - 1) : str.ToString();
}