0

Is there some way to loop through all the levels of treeview nodes .

I have a tree view with xml datasource :

<asp:TreeView ID="tv_products" runat="server" ImageSet="Events" DataSourceID="XmlDataSource1" OnSelectedNodeChanged="DirectoryTree_SelectedNodeChanged" ShowLines="True" OnDataBound="DirectoryTree_DataBound">
           <DataBindings>
                <asp:TreeNodeBinding DataMember="MenuItem" ImageUrl="~/images/folder.png" TextField="fullname" ValueField="maincode" ToolTipField="fullname" />
           </DataBindings>
                 <ParentNodeStyle Font-Bold="False" />
                     <HoverNodeStyle Font-Underline="False" ForeColor="Red" />
                             <SelectedNodeStyle Font-Underline="True" Font-Bold="true" Font-Size="Small" HorizontalPadding="0px" VerticalPadding="0px" />
                             <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" /></asp:TreeView>

Please some example if possible ?

Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392

1 Answers1

1

Write a method which gets tree node as an attribute. Logic of this method should be like going through each child nodes and check whether each child has child node count > 0 if so pass this child node to the method.

As you said you have to check one condition here, you can insert your condition in the code wherever you want.

Hope it helps!!!

Vickyonit
  • 1,077
  • 1
  • 7
  • 8