How to hide a node in the tree at any level.
You can setup the tree for example that will display 2 levels.
<ig:WebDataTree ID="WebDataTree1" runat="server" Height="300px" Width="200px"> <Nodes> <ig:DataTreeNode Text="Root Node 1"> <Nodes> <ig:DataTreeNode Text="Child Node"> </ig:DataTreeNode> <ig:DataTreeNode Text="Child Node"> </ig:DataTreeNode> </Nodes> </ig:DataTreeNode> <ig:DataTreeNode Text="Root Node 2"> <Nodes> <ig:DataTreeNode Text="Child Node"> </ig:DataTreeNode> <ig:DataTreeNode Text="Child Node"> </ig:DataTreeNode> <ig:DataTreeNode Text="Child Node"> </ig:DataTreeNode> </Nodes> </ig:DataTreeNode> <ig:DataTreeNode Text="Root Node 3"> <Nodes> <ig:DataTreeNode Key="44" Text="Child Node 44"> </ig:DataTreeNode> <ig:DataTreeNode Text="Child Node"> </ig:DataTreeNode> </Nodes> </ig:DataTreeNode> </Nodes></ig:WebDataTree>
Public Sub FindNodeByKey(ByRef findNode As DataTreeNode, ByVal node As DataTreeNode, ByVal key As String) For Each childNode As DataTreeNode In node.Nodes If childNode.Key = key Then findNode = childNode End If For Each nextChildNode As DataTreeNode In childNode.Nodes If nextChildNode.Key = key Then findNode = nextChildNode End If FindNodeByKey(findNode, nextChildNode, key) Next NextEnd Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim findNode As DataTreeNode = Nothing For Each node As DataTreeNode In WebDataTree1.Nodes Dim key As String = "44" If node.Key = key Then findNode = node End If FindNodeByKey(findNode, node, key) Next If Not IsNothing(findNode) Then findNode.Visible = False End IfEnd Sub