public void TreeNodeBindingCollection_Method_CopyTo()
        {
            TreeView tv = new TreeView();

            TreeNodeBinding[] bindingArray = new TreeNodeBinding[10];
            tv.DataBindings.Add(new TreeNodeBinding());
            TreeNodeBinding tnb = new TreeNodeBinding();

            tnb.DataMember = "TreeNodeBinding";
            tv.DataBindings.Add(tnb);
            tv.DataBindings.Add(new TreeNodeBinding());
            Assert.AreEqual(3, tv.DataBindings.Count, "BeforeCopyTo");
            tv.DataBindings.CopyTo(bindingArray, 3);
            Assert.AreEqual("TreeNodeBinding", bindingArray[4].DataMember, "AfterCopyTo");
        }
Ejemplo n.º 2
0
        private void DisplayCatagories()
        {
            bool           RequestorCatagories = (_DisplayType == Utility.DisplayTypeAdministrator) ? false : true;
            CatagoriesTree colCatagories       = new CatagoriesTree(PortalId, RequestorCatagories);

            tvCategories.DataSource = colCatagories;

            TreeNodeBinding RootBinding = new TreeNodeBinding();

            RootBinding.DataMember = "ListItem";
            RootBinding.TextField  = "Text";
            RootBinding.ValueField = "Value";

            tvCategories.DataBindings.Add(RootBinding);

            tvCategories.DataBind();
            if (_Expand)
            {
                tvCategories.ExpandAll();
            }
        }
        public void TreeNodeBindingCollection_Method_RemoveAt()
        {
            TreeView        tv   = new TreeView();
            TreeNodeBinding tnb1 = new TreeNodeBinding();

            tnb1.DataMember = "first";
            TreeNodeBinding tnb2 = new TreeNodeBinding();

            tnb2.DataMember = "second";
            TreeNodeBinding tnb3 = new TreeNodeBinding();

            tnb3.DataMember = "third";
            tv.DataBindings.Add(tnb1);
            tv.DataBindings.Add(tnb2);
            tv.DataBindings.Add(tnb3);
            Assert.AreEqual(3, tv.DataBindings.Count, "BeforeRemove1");
            Assert.AreEqual("second", tv.DataBindings[1].DataMember, "BeforeRemove2");
            tv.DataBindings.RemoveAt(1);
            Assert.AreEqual(2, tv.DataBindings.Count, "AfterRemove1");
            Assert.AreEqual("third", tv.DataBindings[1].DataMember, "AfterRemove2");
        }
Ejemplo n.º 4
0
    protected TreeView GenerateTree(DataRow[] menu, DataTable table, String sb,int ID)
    {
        DataTable dtTree = new DataTable();
        dtTree = menu.CopyToDataTable();
        MySource.Data = ConvertDatatableToXML(dtTree,table,sb);

        TreeView tv = new TreeView();
        tv.ID = "Treeview" + ID;
        TreeProperties(tv);

        TreeNodeBinding tNode = new TreeNodeBinding();
        tNode.DataMember = "MsMenuItem";
        tNode.TextField = "title";
        tNode.TargetField = "result";
        tNode.NavigateUrlField = "url";
        tNode.ValueField = "menuid";
        //tNode.ImageUrlField = "imageUrl";
        tv.DataBindings.Add(tNode);

        return tv;
    }
Ejemplo n.º 5
0
        private void DisplayHelpDesk()
        {
            bool         RequestorR7_HelpDesk = (_DisplayType == "Administrator") ? false : true;
            HelpDeskTree colHelpDesk          = new HelpDeskTree(PortalId, RequestorR7_HelpDesk);

            tvCategories.DataSource = colHelpDesk;

            TreeNodeBinding RootBinding = new TreeNodeBinding();

            RootBinding.DataMember = "ListItem";
            RootBinding.TextField  = "Text";
            RootBinding.ValueField = "Value";

            tvCategories.DataBindings.Add(RootBinding);

            tvCategories.DataBind();
            if (_Expand)
            {
                tvCategories.ExpandAll();
            }
        }
Ejemplo n.º 6
0
        public void TreeNodeBinding_DefaultProperties()
        {
            TreeNodeBinding tnb = new TreeNodeBinding();

            Assert.AreEqual(string.Empty, tnb.DataMember, "DataMember");
            Assert.AreEqual(-1, tnb.Depth, "Depth");
            Assert.AreEqual(string.Empty, tnb.FormatString, "FormatString");
            Assert.AreEqual(string.Empty, tnb.ImageToolTip, "ImageToolTip");
            Assert.AreEqual(string.Empty, tnb.ImageToolTipField, "ImageToolTipField");
            Assert.AreEqual(string.Empty, tnb.NavigateUrl, "NavigateUrl");
            Assert.AreEqual(string.Empty, tnb.NavigateUrlField, "NavigateUrlField");
            Assert.AreEqual(false, tnb.PopulateOnDemand, "PopulateOnDemand");
            Assert.AreEqual(TreeNodeSelectAction.Select, tnb.SelectAction, "SelectAction");
            Assert.AreEqual(null, tnb.ShowCheckBox, "ShowCheckBox");
            Assert.AreEqual(string.Empty, tnb.Target, "Target");
            Assert.AreEqual(string.Empty, tnb.TargetField, "TargetField");
            Assert.AreEqual(string.Empty, tnb.Text, "Text");
            Assert.AreEqual(string.Empty, tnb.TextField, "TextField");
            Assert.AreEqual(string.Empty, tnb.ToolTip, "ToolTip");
            Assert.AreEqual(string.Empty, tnb.ToolTipField, "ToolTipField");
            Assert.AreEqual(string.Empty, tnb.Value, "Value");
            Assert.AreEqual(string.Empty, tnb.ValueField, "ValueField");
        }
 private void AddBinding()
 {
     System.Windows.Forms.TreeNode selectedNode = this._schemaTreeView.SelectedNode;
     if (selectedNode != null)
     {
         TreeNodeBinding binding = new TreeNodeBinding();
         if (selectedNode.Text != this._schemaTreeView.Nodes[0].Text)
         {
             binding.DataMember = selectedNode.Text;
             if (((SchemaTreeNode)selectedNode).Duplicate)
             {
                 binding.Depth = selectedNode.FullPath.Split(new char[] { this._schemaTreeView.PathSeparator[0] }).Length - 1;
             }
             ((IDataSourceViewSchemaAccessor)binding).DataSourceViewSchema = ((SchemaTreeNode)selectedNode).Schema;
             int index = this._bindingsListView.Items.IndexOf(binding);
             if (index == -1)
             {
                 this._bindingsListView.Items.Add(binding);
                 this._bindingsListView.SetSelected(this._bindingsListView.Items.Count - 1, true);
             }
             else
             {
                 binding = (TreeNodeBinding)this._bindingsListView.Items[index];
                 this._bindingsListView.SetSelected(index, true);
             }
         }
         else
         {
             this._bindingsListView.Items.Add(binding);
             this._bindingsListView.SetSelected(this._bindingsListView.Items.Count - 1, true);
         }
         this._propertyGrid.SelectedObject = binding;
         this._propertyGrid.Refresh();
         this.UpdateEnabledStates();
     }
     this._bindingsListView.Focus();
 }
Ejemplo n.º 8
0
    protected TreeView GenerateTree(DataRow[] menu, DataTable table, String sb, int ID)
    {
        DataTable dtTree = new DataTable();

        dtTree        = menu.CopyToDataTable();
        MySource.Data = ConvertDatatableToXML(dtTree, table, sb);

        TreeView tv = new TreeView();

        tv.ID = "Treeview" + ID;
        TreeProperties(tv);

        TreeNodeBinding tNode = new TreeNodeBinding();

        tNode.DataMember       = "MsMenuItem";
        tNode.TextField        = "title";
        tNode.TargetField      = "result";
        tNode.NavigateUrlField = "url";
        tNode.ValueField       = "menuid";
        //tNode.ImageUrlField = "imageUrl";
        tv.DataBindings.Add(tNode);

        return(tv);
    }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //WorkflowId = Convert.ToInt32(Context.Items["intWorkflowId"]);
                WorkflowId = Convert.ToInt32(Request.Params["intWorkflowId"]);                
                //lblTituloArbol.Text = "'" + Convert.ToString(Context.Items["strNombre"]) + "'";
                blnConsultar = Convert.ToBoolean(Context.Items["blnConsultar"]);
                //tvWorkflow.Visible = true;
                //tvWorkflow.ExpandLevel = NIVELES_EXPANDIDOS;

                wfTreeView.Visible = true;
                wfTreeView.ExpandAll();

                if (WorkflowId != -1)
                {
                    //tvWorkflow.TreeNodeSrc = WFPolitica.ObtenerRepresentacionXmlConRoles(WorkflowId);
                    //tvWorkflow.DataBind();

                    wfTreeView.DataSource = WFPolitica.ObtenerRepresentacionXmlDataSourceConRoles(WorkflowId);

                    TreeNodeBinding Binding = new TreeNodeBinding();
                    Binding.TextField = "FullName";
                    Binding.ValueField = "ID";
                    wfTreeView.DataBindings.Add(Binding);

                    wfTreeView.DataBind();

                    if (blnConsultar)
                    {
                        lblTitulo.Text = "Workflow > Consultar rutas de aprobación";
                        btnSalir.Text = "Regresar";
                    }
                }
            }
        }
Ejemplo n.º 10
0
        internal TreeNodeBinding FindBindingForNode(string type, int depth)
        {
            if (this.bindings == null)
            {
                return(null);
            }
            TreeNodeBinding binding = (TreeNodeBinding)this.bindings[this.GetBindingKey(type, depth)];

            if (binding != null)
            {
                return(binding);
            }
            binding = (TreeNodeBinding)this.bindings[this.GetBindingKey(type, -1)];
            if (binding != null)
            {
                return(binding);
            }
            binding = (TreeNodeBinding)this.bindings[this.GetBindingKey(string.Empty, depth)];
            if (binding != null)
            {
                return(binding);
            }
            return((TreeNodeBinding)this.bindings[this.GetBindingKey(string.Empty, -1)]);
        }
 public bool Contains(TreeNodeBinding binding)
 {
 }
 public void CopyTo(TreeNodeBinding[] bindingArray, int index)
 {
 }
 public bool Contains(TreeNodeBinding binding)
 {
 }
 // Methods
 public int Add(TreeNodeBinding binding)
 {
 }
 public void Remove(TreeNodeBinding binding)
 {
 }
 public void Insert(int index, TreeNodeBinding binding)
 {
 }
 public int IndexOf(TreeNodeBinding binding)
 {
 }
 public void Remove(TreeNodeBinding binding)
 {
     ((IList)this).Remove(binding);
 }
 public int IndexOf(TreeNodeBinding binding)
 {
     return(((IList)this).IndexOf(binding));
 }
 public int Add(TreeNodeBinding binding)
 {
     return(((IList)this).Add(binding));
 }
Ejemplo n.º 21
0
        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();
            //    }
            //}
        }
 public void Insert(int index, TreeNodeBinding binding)
 {
 }
 // Methods
 public int Add(TreeNodeBinding binding)
 {
 }
 public int IndexOf(TreeNodeBinding binding)
 {
 }
 public void Remove(TreeNodeBinding binding)
 {
 }
 public bool Contains(TreeNodeBinding binding)
 {
     return(((IList)this).Contains(binding));
 }
Ejemplo n.º 27
0
        private void DisplayCategory()
        {
            // Step 1: 데이터가져오기: 추후 DB에서 가져오면 됨
            // Create the DataTable and columns
            DataTable dt = new DataTable("MarketCategory");

            dt.Columns.Add("CategoryId", typeof(int));
            dt.Columns.Add("CategoryName", typeof(String));
            dt.Columns.Add("SuperCategory", typeof(int));
            dt.Columns.Add("Align", typeof(int));

            // Add some test data
            dt.Rows.Add(new object[] { 0, "카테고리", -1, 0 }); // 최고 부모로 봄
            dt.Rows.Add(new object[] { 1, "컴퓨터", 0, 0 });
            dt.Rows.Add(new object[] { 2, "서적", 0, 1 });
            dt.Rows.Add(new object[] { 3, "강의", 0, 2 });
            dt.Rows.Add(new object[] { 4, "데스크톱", 1, 0 });
            dt.Rows.Add(new object[] { 5, "노트북", 1, 1 });
            dt.Rows.Add(new object[] { 6, "삼성", 5, 0 });
            dt.Rows.Add(new object[] { 7, "LG", 5, 1 });

            // Use the Select method to sort the rows by SuperCategory
            DataRow[] sortedCategories = dt.Select("", "CategoryId");

            // Step 2: XmlDocument 개체에 담기
            // Create an XmlDocument (with an XML declaration)
            XmlDocument    doc     = new XmlDocument();
            XmlDeclaration declare = doc.CreateXmlDeclaration("1.0", null, null);

            doc.AppendChild(declare);

            // iterate through the sorted data and build the XML document
            foreach (DataRow row in sortedCategories)
            {
                // Create an element node to insert
                // note: Element names may not have spaces so use ID
                // note: Element names may not start with a digit so add underscore
                XmlElement node = doc.CreateElement("_" + row["CategoryId"].ToString());
                node.SetAttribute("CategoryId", row["CategoryId"].ToString());
                node.SetAttribute("CategoryName", row["CategoryName"].ToString());
                node.SetAttribute("SuperCategory", row["SuperCategory"].ToString());
                node.SetAttribute("Align", row["Align"].ToString());

                // special case for top level node
                if ((int)row["SuperCategory"] == -1)
                {
                    doc.AppendChild(node); // root node
                }
                else
                {
                    // use XPath to find the parent node in the tree
                    string  searchString = String.Format("//*[@CategoryId=\"{0}\"] ", row["SuperCategory"].ToString());
                    XmlNode parent       = doc.SelectSingleNode(searchString);

                    if (parent != null)
                    {
                        parent.AppendChild(node);
                    }
                    else
                    {
                        ; // Handle Error: Category with no boss
                    }
                }
            }


            // Step 3: 트리뷰에 추가하기
            // we cannot bind the TreeView directly to an XmlDocument
            // so we must create an XmlDataSource and assign the XML text
            XmlDataSource xmlDataSource = new XmlDataSource();

            xmlDataSource.ID   = DateTime.Now.Ticks.ToString(); // unique ID is required
            xmlDataSource.Data = doc.OuterXml;

            // we want the full name displayed in the tree so
            // do custom databindings
            TreeNodeBinding binding = new TreeNodeBinding();

            binding.TextField  = "CategoryName";
            binding.ValueField = "CategoryId";
            ctlCategoryListWithTreeView.DataBindings.Add(binding);

            // Finally! Hook that bad boy up!
            ctlCategoryListWithTreeView.DataSource = xmlDataSource;
            ctlCategoryListWithTreeView.DataBind();
        }
 public void Insert(int index, TreeNodeBinding binding)
 {
     ((IList)this).Insert(index, binding);
 }
Ejemplo n.º 29
0
        internal void Bind(IHierarchyData hierarchyData)
        {
            this.hierarchyData = hierarchyData;
            this.DataBound     = true;
            this.DataPath      = hierarchyData.Path;
            this.dataItem      = hierarchyData.Item;
            TreeNodeBinding binding = this.GetBinding();

            if (binding != null)
            {
                if (binding.ImageUrlField.Length > 0)
                {
                    this.ImageUrl = Convert.ToString(this.GetBoundPropertyValue(binding.ImageUrlField));
                }
                if (string.IsNullOrEmpty(this.ImageUrl) && (binding.ImageUrl.Length > 0))
                {
                    this.ImageUrl = binding.ImageUrl;
                }
                if (binding.TargetField.Length > 0)
                {
                    this.Target = Convert.ToString(this.GetBoundPropertyValue(binding.TargetField));
                    if (this.Target.Length == 0)
                    {
                        this.Target = binding.Target;
                    }
                }
                else if (binding.Target.Length > 0)
                {
                    this.Target = binding.Target;
                }
                string text = null;
                if (binding.TextField.Length > 0)
                {
                    text = Convert.ToString(this.GetBoundPropertyValue(binding.TextField));
                    if (binding.FormatString.Length > 0)
                    {
                        text = string.Format(binding.FormatString, text);
                    }
                }
                if (string.IsNullOrEmpty(text))
                {
                    if (binding.Text.Length > 0)
                    {
                        text = binding.Text;
                    }
                    else if (binding.Value.Length > 0)
                    {
                        text = binding.Value;
                    }
                }
                if (!string.IsNullOrEmpty(text))
                {
                    this.Text = text;
                }
                if (binding.ToolTipField.Length > 0)
                {
                    this.ToolTip = Convert.ToString(this.GetBoundPropertyValue(binding.ToolTipField));
                }
                if (string.IsNullOrEmpty(this.ToolTip) && (binding.ToolTip.Length > 0))
                {
                    this.ToolTip = binding.ToolTip;
                }
                string str2 = null;
                if (binding.ValueField.Length > 0)
                {
                    str2 = Convert.ToString(this.GetBoundPropertyValue(binding.ValueField));
                }
                if (string.IsNullOrEmpty(str2))
                {
                    if (binding.Value.Length > 0)
                    {
                        str2 = binding.Value;
                    }
                    else if (binding.Text.Length > 0)
                    {
                        str2 = binding.Text;
                    }
                }
                if (!string.IsNullOrEmpty(str2))
                {
                    this.Value = str2;
                }
                else
                {
                    this.Text = this.Value = this.GetDefaultBoundText();
                }
                if (binding.NavigateUrlField.Length > 0)
                {
                    this.NavigateUrl = Convert.ToString(this.GetBoundPropertyValue(binding.NavigateUrlField));
                    if (this.NavigateUrl.Length == 0)
                    {
                        this.NavigateUrl = binding.NavigateUrl;
                    }
                }
                else if (binding.NavigateUrl.Length > 0)
                {
                    this.NavigateUrl = binding.NavigateUrl;
                }
            }
            else
            {
                this.Text = this.Value;
            }
        }
Ejemplo n.º 30
0
        public void Initialize()
        {
            lstNiveles.Items.Clear();
            lstEscogencia.Items.Clear();

            System.Web.UI.WebControls.TreeView wft = (System.Web.UI.WebControls.TreeView)Web.Global.FindMyControl(Page, "wfTreeView");
            wft.Visible = true;
            wft.ExpandAll();
            //NodeIndex = wft.SelectedValue;

            if (WorkflowId != -1 && FirstTime)
            {
                FirstTime      = false;
                wft.DataSource = WFPolitica.ObtenerRepresentacionXmlDataSourceConRutas(WorkflowId);

                // we want the full name displayed in the tree so
                // do custom databindings
                TreeNodeBinding Binding = new TreeNodeBinding();
                Binding.TextField  = "FullName";
                Binding.ValueField = "ID";
                wft.DataBindings.Add(Binding);

                wft.DataBind();
            }

            System.Web.UI.WebControls.TreeNode tn = Global.GetNodeFromPath(wft.Nodes, NodeIndex);
            if (tn == null || tn.ChildNodes.Count > 1)
            {
                return;                                        //MOSTRAR ALGUN MENSAJE DE ALARMA: no es una hoja donde se pueda conseguir una ruta
            }
            int ID = 0;

            if (tn.Value[0] == 'R')
            {
                ID = Convert.ToInt32(tn.Value.Substring(2));

                //lstNiveles.DataSource = WFGrupoDeRoles.ObtenerGruposDeRolesExcepto(ID);
                lstNiveles.DataSource     = WFGrupoDeRoles.ObtenerGruposDeRolesExcepto(0);
                lstNiveles.DataTextField  = "strNbrRoles";
                lstNiveles.DataValueField = "intCodRoles";
                lstNiveles.DataBind();

                lstEscogencia.DataSource     = WFGrupoDeRoles.ObtenerGruposDeRoles(ID, tn.Text);
                lstEscogencia.DataTextField  = "strNbrRoles";
                lstEscogencia.DataValueField = "intCodRoles";
                lstEscogencia.DataBind();
            }
            else
            {
                lstNiveles.DataSource     = WFGrupoDeRoles.ObtenerGruposDeRolesExcepto(ID);
                lstNiveles.DataTextField  = "strNbrRoles";
                lstNiveles.DataValueField = "intCodRoles";
                lstNiveles.DataBind();
            }

            /*
             * Microsoft.Web.UI.WebControls.TreeView tvw = (Microsoft.Web.UI.WebControls.TreeView)Page.FindControl("tvWorkflow");
             *          if(WorkflowId != -1 && FirstTime)
             *          {
             *                  FirstTime = false;
             *                  tvw.TreeNodeSrc = WFPolitica.ObtenerRepresentacionXmlConRutas(WorkflowId);
             *                  tvw.DataBind();
             *          }
             *
             *          tvw.Visible = true;
             *          tvw.AutoPostBack = true;
             *          tvw.ExpandLevel = NIVELES_EXPANDIDOS;
             *
             *          NodeIndex = tvw.SelectedNodeIndex;
             *          Microsoft.Web.UI.WebControls.TreeNode tn = tvw.GetNodeFromIndex(NodeIndex);
             *          int ID = 0;
             *          if(tn != null)
             *          {
             *                  if(tn.NodeData[0] != 'N')
             *                  {
             *                          ID = Convert.ToInt32(tn.NodeData);
             *
             *                          lstNiveles.DataSource = WFGrupoDeRoles.ObtenerGruposDeRolesExcepto(ID);
             *                          lstNiveles.DataTextField = "strNbrRoles";
             *                          lstNiveles.DataValueField = "intCodRoles";
             *                          lstNiveles.DataBind();
             *
             *                          lstEscogencia.DataSource = WFGrupoDeRoles.ObtenerGruposDeRoles(ID,tn.Text);
             *                          lstEscogencia.DataTextField = "strNbrRoles";
             *                          lstEscogencia.DataValueField = "intCodRoles";
             *                          lstEscogencia.DataBind();
             *                  }
             *                  else
             *                  {
             *                          lstNiveles.DataSource = WFGrupoDeRoles.ObtenerGruposDeRolesExcepto(ID);
             *                          lstNiveles.DataTextField = "strNbrRoles";
             *                          lstNiveles.DataValueField = "intCodRoles";
             *                          lstNiveles.DataBind();
             *                  }
             *          }*/
        }
Ejemplo n.º 31
0
        // Tags

        #region DisplayHelpDesk
        private void DisplayHelpDesk()
        {
            HelpDeskTree colHelpDesk = new HelpDeskTree(PortalId, false);

            tvCategories.DataSource = colHelpDesk;

            TreeNodeBinding RootBinding = new TreeNodeBinding();

            RootBinding.DataMember = "ListItem";
            RootBinding.TextField  = "Text";
            RootBinding.ValueField = "Value";

            tvCategories.DataBindings.Add(RootBinding);

            tvCategories.DataBind();
            tvCategories.CollapseAll();

            // If a node was selected previously select it again
            if (txtCategoryID.Text != "")
            {
                int      intCategoryID = Convert.ToInt32(txtCategoryID.Text);
                TreeNode objTreeNode   = (TreeNode)tvCategories.FindNode(GetNodePath(intCategoryID));
                objTreeNode.Select();
                objTreeNode.Expand();

                // Expand it's parent nodes
                // Get the value of each parent node
                string[] strParentNodes = objTreeNode.ValuePath.Split(Convert.ToChar("/"));
                // Loop through each parent node
                for (int i = 0; i < objTreeNode.Depth; i++)
                {
                    // Get the parent node
                    TreeNode objParentTreeNode = (TreeNode)tvCategories.FindNode(GetNodePath(Convert.ToInt32(strParentNodes[i])));
                    // Expand the parent node
                    objParentTreeNode.Expand();
                }
            }
            else
            {
                //If there is at least one existing category, select it
                if (tvCategories.Nodes.Count > 0)
                {
                    tvCategories.Nodes[0].Select();
                    txtCategoryID.Text = "0";
                    SelectTreeNode();
                }
                else
                {
                    // There is no data so set form to Add New
                    SetFormToAddNew();
                }
            }

            // If a node is selected, remove it from the BindDropDown drop-down
            int      intCategoryNotToShow = -1;
            TreeNode objSelectedTreeNode  = (TreeNode)tvCategories.SelectedNode;

            if (objSelectedTreeNode != null)
            {
                intCategoryNotToShow = Convert.ToInt32(tvCategories.SelectedNode.Value);
            }

            BindDropDown(intCategoryNotToShow);
        }