public ActionResult GetFormTreeJson() { var data = formmodulebll.GetAllList(); var treeList = new List <TreeEntity>(); string FrmType = ""; foreach (DataRow item in data.Rows) { TreeEntity tree = new TreeEntity(); if (FrmType != item["FrmCategory"].ToString()) { TreeEntity tree1 = new TreeEntity(); FrmType = item["FrmCategory"].ToString(); tree1.id = FrmType; tree1.text = item["FrmTypeName"].ToString(); tree1.value = FrmType; tree1.isexpand = true; tree1.complete = true; tree1.hasChildren = true; tree1.parentId = "0"; tree1.img = "fa fa-list-alt"; tree1.Attribute = "Sort"; tree1.AttributeValue = "FrmType"; treeList.Add(tree1); } tree.id = item["FrmId"].ToString(); tree.text = item["FrmName"].ToString(); tree.value = item["FrmId"].ToString(); tree.isexpand = true; tree.complete = true; tree.hasChildren = false; tree.parentId = FrmType; tree.Attribute = "Sort"; tree.AttributeValue = "Frm"; treeList.Add(tree); } return(Content(treeList.TreeToJson())); }