public void Button_Command(Object sender, CommandEventArgs e) { switch (e.CommandName) { case "Expand": if (panel_sample.Visible == true) { TreeView1.ExpandAll(); } else { TreeView2.ExpandAll(); } break; case "Collapse": if (panel_sample.Visible == true) { TreeView1.CollapseAll(); } else { TreeView2.CollapseAll(); } break; default: // Do nothing. break; } }
private void ShowFormPanel(string Role_ID) { pnlGrid.Visible = false; pnlForm.Visible = true; if (!string.IsNullOrEmpty(Role_ID)) { dbo_RoleClass role = dbo_RoleDataClass.Select_Record(Role_ID); txtRole_ID.Text = role.Role_ID; txtRole_Name.Text = role.Role_Name; TreeView2.Nodes.Clear(); TreeView2.ShowLines = false; List <MenuNode> RootNode = dbo_RolePermissionDataClass.GetMenuNode(int.Parse(txtRole_ID.Text)); BindTree(RootNode, null); TreeView2.ExpandAll(); TreeView2.ShowLines = false; } }
private void InitialTreeView() { TreeView2.Nodes.Clear(); List <MenuNode> RootNode = dbo_RolePermissionDataClass.GetMenuNode(-1); BindTree(RootNode, null); TreeView2.ExpandAll(); TreeView2.ShowLines = false; }
protected void bindtreeviewMaping() { try { this.TreeView2.Nodes.Clear(); HierarchyTree hierarchy = new HierarchyTree(); HierarchyTree.HGroup objhtree = null; string selgroup = "select distinct ITGroupPK,GroupName,ParentCode from IT_GroupMaster where CollegeCode='" + ddlcolload.SelectedItem.Value + "'"; ds.Clear(); ds = d2.select_method_wo_parameter(selgroup, "Text"); this.TreeView2.Nodes.Clear(); hierarchy.Clear(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { objhtree = new HierarchyTree.HGroup(); objhtree.group_code = int.Parse(ds.Tables[0].Rows[i]["ITGroupPK"].ToString()); objhtree.parent_code = int.Parse(ds.Tables[0].Rows[i]["ParentCode"].ToString()); objhtree.group_name = ds.Tables[0].Rows[i]["GroupName"].ToString(); hierarchy.Add(objhtree); } foreach (HierarchyTree.HGroup hTree in hierarchy) { HierarchyTree.HGroup parentNode = hierarchy.Find(delegate(HierarchyTree.HGroup emp) { return(emp.group_code == hTree.parent_code); }); if (parentNode != null) { foreach (TreeNode tn in TreeView2.Nodes) { if (tn.Value == parentNode.group_code.ToString()) { tn.ChildNodes.Add(new TreeNode(hTree.group_name.ToString(), hTree.group_code.ToString())); } if (tn.ChildNodes.Count > 0) { foreach (TreeNode ctn in tn.ChildNodes) { RecursiveChild(ctn, parentNode.group_code.ToString(), hTree); } } } } else { TreeView2.Nodes.Add(new TreeNode(hTree.group_name, hTree.group_code.ToString())); } TreeView2.ExpandAll(); //TreeView2.ExpandAll(); } } catch { } }
private void toPopulateTreeview() { string dt_topics = ""; string dt_topics1 = ""; string subjectno = ddlsubject.SelectedValue.ToString(); if (!string.IsNullOrEmpty(subjectno)) { con.Close(); con.Open(); //this.TreeView1.Nodes.Clear(); HierarchyTrees hierarchyTrees = new HierarchyTrees(); HierarchyTrees.HTree objHTree = null; //start=======common tree load using (SqlCommand command = new SqlCommand("select topic_no,parent_code,unit_name from sub_unit_details where subject_no='" + subjectno + "' order by parent_code,topic_no ", con)) { //this.TreeView1.Nodes.Clear(); hierarchyTrees.Clear(); SqlDataReader reader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection); while (reader.Read()) { objHTree = new HierarchyTrees.HTree(); objHTree.topic_no = int.Parse(reader["Topic_no"].ToString()); objHTree.parent_code = int.Parse(reader["parent_code"].ToString()); objHTree.unit_name = reader["unit_name"].ToString(); hierarchyTrees.Add(objHTree); } } foreach (HierarchyTrees.HTree hTree in hierarchyTrees) { HierarchyTrees.HTree parentNode = hierarchyTrees.Find(delegate(HierarchyTrees.HTree emp) { return(emp.topic_no == hTree.parent_code); } ); if (parentNode != null) { foreach (TreeNode tn in TreeView2.Nodes) { if (tn.Value == parentNode.topic_no.ToString()) { tn.ChildNodes.Add(new TreeNode(hTree.unit_name.ToString(), hTree.topic_no.ToString())); //Session["session_tnValue"] = tn; } if (tn.ChildNodes.Count > 0) { foreach (TreeNode ctn in tn.ChildNodes) { RecursiveChild(ctn, parentNode.topic_no.ToString(), hTree); } } } } else { TreeView2.Nodes.Add(new TreeNode(hTree.unit_name, hTree.topic_no.ToString())); } TreeView2.ExpandAll(); } TreeView2.ExpandAll(); if (TreeView2.Nodes.Count < 1) { } else { TreeView2.Visible = true; btnsave.Visible = true; } } }
private void Page_Load(object sender, System.EventArgs e) { if (StateManager.IsManualState()) { // If the StateManager doesn't exist in the session put it else get it. if (StateManager.GetStateManagerFromSession() == null) { //instanciate AppStateManager class AppStateManager myStateManager = new AppStateManager(); //put state manager to session StateManager.PutStateManagerInSession(myStateManager); //put current map alias to state manager dictionary myStateManager.ParamsDictionary[StateManager.ActiveMapAliasKey] = this.MapControl1.MapAlias; } // Now Restore State StateManager.GetStateManagerFromSession().RestoreState(); } if (!Page.IsPostBack) { #region 加载节点地图数据 Map mainMap = GetMap(); FeatureLayer flStation = mainMap.Layers["Station"] as FeatureLayer; FeatureLayer flBaseStation = mainMap.Layers["BaseStation"] as FeatureLayer; FeatureLayer flSubMachine = mainMap.Layers["SubMachine"] as FeatureLayer; //加载主站 foreach (Feature fStation in (flStation.Table as MapInfo.Data.ITableFeatureCollection)) { TreeNode tn = new TreeNode(fStation["NAME"].ToString()); tn.Target = fStation["ID"].ToString(); tn.ImageUrl = Request.MapPath("~/images/1.gif"); tn.CollapseAll(); TreeView2.Nodes.Add(tn); } //加载基站 foreach (Feature fBaseStation in (flBaseStation.Table as MapInfo.Data.ITableFeatureCollection)) { TreeNode pNode = GetParentStation(fBaseStation["PID"].ToString()); if (pNode == null) { continue; } TreeNode tn = new TreeNode(fBaseStation["NAME"].ToString()); tn.Target = fBaseStation["ID"].ToString(); tn.ImageUrl = Request.MapPath("~/images/2.gif"); tn.CollapseAll(); pNode.ChildNodes.Add(tn); } //加载子机 foreach (Feature fSubMachine in (flSubMachine.Table as MapInfo.Data.ITableFeatureCollection)) { TreeNode pNode = GetBaseStation(fSubMachine["PID"].ToString()); if (pNode == null) { continue; } TreeNode tn = new TreeNode(fSubMachine["NAME"].ToString()); tn.Target = fSubMachine["ID"].ToString(); tn.ImageUrl = Request.MapPath("~/images/3.gif"); tn.CollapseAll(); pNode.ChildNodes.Add(tn); } TreeView2.ExpandAll(); #endregion } }