private void ShowMenuSections()
        {
            TreeNodeBinding tnb = new TreeNodeBinding();

            tnb.DataMember       = "System.Data.DataRowView";
            tnb.TextField        = "TabName";
            tnb.ValueField       = "TabId";
            tnb.PopulateOnDemand = false;
            tnb.SelectAction     = TreeNodeSelectAction.Select;
            TreeView1.DataBindings.Add(tnb);

            TabController tab_obj = new TabController();
            DataSet       dataSet = tab_obj.GetActiveList();

            // You can use this:
            TreeView1.DataSource = new HierarchicalDataSet(dataSet, "TabId", "ParentId");

            // OR you can use the extensions for TreeView if you are using .NET 3.5
            //TreeView1.SetDataSourceFromDataSet(dataSet, "Idx", "ParentId");

            // OR This line, will load the tree starting from the parent record of value = 1
            //TreeView1.DataSource = new HierarchicalDataSet(dataSet, "Idx", "ParentId", 1);
            TreeView1.DataBind();
            TreeView1.CollapseAll();
        }
示例#2
0
        private void LoadTabList2DDL()
        {
            ddlTabList.Items.Clear();

            TabController tab_obj = new TabController();
            DataSet       ds      = tab_obj.GetActiveList(); //select all the nodes from DB

            ddlTabList.DataSource     = ds.Tables[0];
            ddlTabList.DataTextField  = "TabName";
            ddlTabList.DataValueField = "TabId";
            ddlTabList.DataBind();
            ddlTabList.Items.Insert(0, new ListItem("- Chọn -", "0"));
            ddlTabList.SelectedIndex = 1;
            ddlTabList.Enabled       = false;
        }
        private void loadMenuSections(int role_id)
        {
            TreeNodeBinding tnb = new TreeNodeBinding();

            tnb.DataMember       = "System.Data.DataRowView";
            tnb.TextField        = "TabName";
            tnb.ValueField       = "TabId";
            tnb.PopulateOnDemand = false;
            tnb.SelectAction     = TreeNodeSelectAction.Select;
            TreeView1.DataBindings.Add(tnb);

            TabController tab_obj = new TabController();
            DataSet       dataSet = tab_obj.GetActiveList();

            // You can use this:
            TreeView1.DataSource = new HierarchicalDataSet(dataSet, "TabId", "ParentId");

            // OR you can use the extensions for TreeView if you are using .NET 3.5
            //TreeView1.SetDataSourceFromDataSet(dataSet, "Idx", "ParentId");

            // OR This line, will load the tree starting from the parent record of value = 1
            //TreeView1.DataSource = new HierarchicalDataSet(dataSet, "Idx", "ParentId", 1);
            TreeView1.DataBind();
            TreeView1.CollapseAll();

            //string menustring = tab_obj.GetMenuStringByRole(role_id);
            //string[] arr_result = menustring.Split(new string[] { "," }, StringSplitOptions.None);

            //for (int index = 0; index < arr_result.Length - 1; index++)
            //{
            //    //if(TreeView1.Nodes.Count>0){
            //    //    foreach (TreeNode nodes in TreeView1.Nodes)
            //    //    {
            //    //        if (arr_result[index].ToString() == nodes.Value)
            //    //        {
            //    //            nodes.Checked = true;
            //    //            nodes.Expand();

            //    //            if (nodes.ChildNodes.Count > 0)
            //    //            {
            //    //                foreach (TreeNode child_nodes in nodes.ChildNodes)
            //    //                {
            //    //                    if (arr_result[index].ToString() == child_nodes.Value)
            //    //                    {
            //    //                        child_nodes.Checked = true;
            //    //                        child_nodes.Expand();
            //    //                    }
            //    //                }
            //    //            }
            //    //        }
            //    //    }
            //    //}

            //    TreeNode nodes = SelectNode(arr_result[index].ToString(), TreeView1.Nodes);
            //    if (nodes != null)
            //    {
            //        nodes.Checked = true;
            //        nodes.Expand();
            //    }
            //}
        }