Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
how to get treeview nodes value in asp.net
i want treeview selected node value in label by their selected nodewise
reply
Posted

1 solution

As your question is not that much clear to give you a proper solution still i am trying here to give you some choices to get the solution or a hint to your solution.

Let say my TreeView name is 'tvTest'. Now the design for it is :-

ASP.NET
<asp:treeview runat="server" id="tvTest" xmlns:asp="#unknown">
        <nodes>
            <asp:treenode text="Item 1">
                <asp:treenode text="Item 1.1"></asp:treenode>
                <asp:treenode text="Item 1.2"></asp:treenode>
                <asp:treenode text="Item 1.3"></asp:treenode>
            </asp:treenode>
            <asp:treenode text="Item 2">
                <asp:treenode text="Item 2.1"></asp:treenode>
                <asp:treenode text="Item 2.2"></asp:treenode>
            </asp:treenode>
            
            <asp:treenode text="Item 3">
                <asp:treenode text="Item 3.1"></asp:treenode>
            </asp:treenode>
        </nodes>
    </asp:treeview>


To get SelectedNode value only we can go by two ways like :-
C#
tvTest.SelectedValue
tvTest.SelectedNode.Value

To get the selected node text :-
C#
tvTest.SelectedNode.Text


To get the path for the values from parent to current :-
C#
tvTest.SelectedNode.ValuePath


Hope this will be of help to you.
Please let me know if you need help on any other way ?
 
Share this answer
 
Comments
Shri006 5-Jul-14 5:37am    
tx u but i need onclick get text/value from clickble node..n

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900