日期:2014-05-17 浏览次数:20735 次
TreeView1.Nodes.Clear(); List<CYXTMS.Model.View_YM_GN> nodeList = viewBLL.GetList((int)vupModel.GN_ID); TreeNode temp; foreach (var node in nodeList) { temp = new TreeNode(node.GN_MC, node.GN_ID.ToString()); if (!string.IsNullOrEmpty(node.YM_URL)) { temp.NavigateUrl = node.YM_URL; temp.Target = "tabFrame"; } else { temp.SelectAction = TreeNodeSelectAction.Expand; } TreeView1.Nodes.Add(temp); } IntiChildNodes(TreeView1.Nodes); foreach (TreeNode node in TreeView1.Nodes) { node.ImageUrl = node.ChildNodes.Count > 0 ? "~/images/themes/default/images/tree/folder.gif" : "images/themes/default/images/tree/leaf.gif"; } /// <summary> /// 递归绑定功能 /// </summary> /// <param name="nodes"></param> private void IntiChildNodes(TreeNodeCollection nodes) { List<CYXTMS.Model.View_YM_GN> viewList; TreeNode tempChild; int tempID = -1; foreach (TreeNode item in nodes) { if (int.TryParse(item.Value ,out tempID)) { viewList = viewBLL.GetList(tempID); foreach (var treeNode in viewList) { tempChild = new TreeNode(treeNode.GN_MC, treeNode.GN_ID.ToString()); if (!string.IsNullOrEmpty(treeNode.YM_URL)) { tempChild.NavigateUrl = treeNode.YM_URL; tempChild.Target = "tabFrame"; } else { tempChild.SelectAction = TreeNodeSelectAction.Expand; } item.ChildNodes.Add(tempChild); if (int.TryParse(tempChild.Value, out tempID)) { if (gnBLL.GetCount(tempID) > 0) { tempChild.ImageUrl = "images/themes/default/images/tree/folder.gif"; IntiChildNodes(item.ChildNodes); } else { tempChild.ImageUrl = "images/themes/default/images/tree/leaf.gif"; } } } } } }