RadTreeView for ASP.NET

The state is not persisted after URL navigation Send comments on this topic.
TroubleShooting > The state is not persisted after URL navigation

Glossary Item Box

When the page is redirected by using the NavigateUrl property of the RadTreeNode class, the state of the treeview is not persisted. Actually, this behavior is typical for all APS.NET controls. If you need, however, to retain the expanded TreeNodes after the URL navigation, you can use the approach described below:

Example:

Consider the following scenario:

All nodes have unique Value properties (i.e 1,2,3...). They also have unique NavigateUrl properties pointing to one page but with different id Get parameter, i.e ( "?Page.aspx&id=1", "?Page.aspx&id=2" ..)

In the Page_Load method of the page you can get the id attribute from the query string, find the node in the tree and mark it as selected and expand nodes up the tree, e.g.

C# Copy Code
if (Request.QueryString["id"] != null)
{
     
string id = Request.QueryString["id"];
     
foreach (RadTreeNode node in RadTree1.GetAllNodes())
     {
           
if (node.Value == id)
           {
                 node.ExpandParentNodes();
                 node.Selected = true;
           }
     }
}