Programatic TreeView Not Persist Its State

4 posts, 1 answers
  1. Shafees
    Shafees avatar
    14 posts
    Member since:
    Sep 2010

    Posted 21 Sep 2010 Link to this post

    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.

     

     

     

  2. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 23 Sep 2010 Link to this post

    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
  3. Shafees
    Shafees avatar
    14 posts
    Member since:
    Sep 2010

    Posted 26 Sep 2010 Link to this post

    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 
  4. Answer
    Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 27 Sep 2010 Link to this post

    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
Back to Top