Categories
General (9)
General ASP.Net (6)
Javascript (6)
ASP.Net WebForms (6)
GridView Controls (7)
ASP.Net AJAX (2)
ASP.Net MVC (1)
 
 
Archive
Aug 2010 (1)
Jul 2010 (1)
Jun 2010 (1)
May 2010 (1)
Apr 2010 (1)
Mar 2010 (1)
Feb 2010 (2)
Jan 2010 (1)
Dec 2009 (2)
Nov 2009 (5)
Oct 2009 (10)
Sep 2009 (6)
Aug 2009 (2)
 
 
7607 Visits
 

Path of TreeNode

How do I get the full path of TreeNode, all the way from the Root node?

Each TreeNode has a property ValuePath which gives the full path of TreeNode from the Root node. All node values, from the Root node, are appended with a separator. Each node value is separated by the PathSeparator attribute of TreeView control. Here is an example:

<asp:TreeView ID="tvw" runat="server" PathSeparator="\">
    <Nodes>
        <asp:TreeNode Text="C:" Value="C:">
            <asp:TreeNode Text="Abc" Value="Abc"></asp:TreeNode>
        </asp:TreeNode>
    </Nodes>
</asp:TreeView>
void tvw_SelectedNodeChanged(object sender, EventArgs e)
{
    Response.Write(tvw.SelectedNode.ValuePath);
}

Name:  
Blog URL: http://  
Comment:  
Gk writes: 04-Jun-2010 09:51 PM
This is too simple for a blogpost ..