This is a migrated thread and some comments may be shown as answers.

Programatic TreeView Not Persist Its State

3 Answers 65 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Shafees
Top achievements
Rank 2
Shafees asked on 21 Sep 2010, 08:50 AM
i have a treeView in master page which is generated compltly on code behind and it is added to a place holder.
Problem is that the tree view is always in its first state when navigate from a page to new page.
Data is taken from dataBase
eg: TreeView look like

Select
    *Company
    *Company Role

intialy its like

Select

and when i select Company, the treeview is in the state

Select
itself

but i need

Select
    *Company
    *Company Role

My Code Look Like

 

public partial class Home : System.Web.UI.MasterPage
{
    protected void Page_Init(object sender, EventArgs e)
    {
        RadTreeView m1 = new RadTreeView();
  
        DynamicMenuBLL objDynMainMenu = new DynamicMenuBLL();
        m1 = objDynMainMenu.GetMenuTree();
  
        placeHolder.Controls.Add(m1);
    }
  
    protected void Page_Load(object sender, EventArgs e)
    {
  
    }
}

please give a solution.

Thank You.

 

 

 

3 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 23 Sep 2010, 12:37 PM
Hello Shafees,

Well, the problem is that using the TreeView in masterPage for an instance, results the following way:
- navigation to a new content page is actually a total navigation to a totally new page.

This way the state is logically lost on every navigation to a different content page.

The solution to this problem would be to persist the state (which node has navigated last/last selected node) in a cookie on the client or in the session on the server.

Hope this is helpful for you!


Regards,
Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Shafees
Top achievements
Rank 2
answered on 26 Sep 2010, 08:32 AM
Thank You for the solution.

My Tree View contain  large number of nodes and sub nodes. Is there any way to get the states at one hand(like viewState) to store it on Session or cookie. Can u show it with a sample code.

Thank You 
0
Accepted
Nikolay Tsenkov
Telerik team
answered on 27 Sep 2010, 04:29 PM
Hi Shafees,

You could use GetXml method over the TreeView Server object (and to reload LoadXml). But considering the big amount of nodes that you mentioned, you probably should store only the important data about your TreeView.

Hope this is helpful for you!


Regards,
Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Shafees
Top achievements
Rank 2
Answers by
Nikolay Tsenkov
Telerik team
Shafees
Top achievements
Rank 2
Share this question
or