标签:rem ble else foreach bsp ext row reac string
组装json对象
public string strTree(DataTable dt, string type, string state) { string strjosn = ""; foreach (DataRow dr in dt.Rows) { if (string.IsNullOrEmpty(strjosn)) { strjosn = "{\"id\":\"" + dr[1] + "\",\"text\":\"" + dr[0] + "\",\"state\":\"" + state + "\",\"attributes\":{\"type\":\"" + type + "\"}}"; } else { strjosn += "," + "{\"id\":\"" + dr[1] + "\",\"text\":\"" + dr[0] + "\",\"state\":\"" + state + "\",\"attributes\":{\"type\":\"" + type + "\"}}"; } } strjosn = "[" + strjosn + "]"; return strjosn; }
标签:rem ble else foreach bsp ext row reac string
原文地址:https://www.cnblogs.com/macT/p/12068150.html