Tuesday, March 13, 2012

Setting Treeview Parent nodes links/Controling node links

How do I set the link for the parent node to open that node? When I click on the folder icon the node opens up but when I click on the node text I get a postback:

javascript:__doPostBack('ctl00$placeHolderMain$Reports1$tvReportGroups','sXXX')

Using the image above as an example, how do I set the "student" link to go to open the student node? Or navigate to xyz.aspx page?


Thanks for any help.

Hello,

Assuming that you have such code, you just putNavigateUrl to do your navigation like this:

<asp:TreeView ID="TreeView2" ExpandDepth="1" runat="server">
<Nodes>
<asp:TreeNode Text="Employees"NavigateUrl="~/con1.aspx">
<asp:TreeNode Text="Bradley" Value="ID-1234"NavigateUrl="~/con1.aspx"/>
<asp:TreeNode Text="Whitney" Value="ID-5678" />
<asp:TreeNode Text="Barbara" Value="ID-9101" />
</asp:TreeNode>
</Nodes>
</asp:TreeView>

As long as you like, you can add url to every node.

0 comments:

Post a Comment