Custom RadTreeNode missing during PostBack Event

5 posts, 0 answers
  1. Polymorphic Solutions
    Polymorphic Solutions avatar
    5 posts
    Member since:
    Sep 2009

    Posted 22 Feb 2010 Link to this post


    I just tried to populate the RadTreeView control dynamically from code behind using a custom user control added to each Node item and I am curious with the non-persistence state of the Node item data during the Page PostBack. My Node item seems to keep missing from the TreeView everytime the Page is posting back.

    For background information, I did not use the DataBinding method and had to manually added the Node item into the TreeView as the database structure that I had does not have the parent-child relationship defined in one table, instead I have to go to three different database tables to link them together in order to get the parent-child relationship for building the TreeView.

    I've set the EnableViewState properties of both the RadTreeView and every node item contained in that TreeView but the node item still keep missing. I can repopulate the node item in the TreeView every PostBack event to keep the Node item there, but that means I will loose the event information especially the Drag-N-Drop event.

    The situation does not happen if I don't use the custom user control, but I will need the custom control as the standard Node item style does not suit my needs.

    Is there anything that you can suggest to me to solve this issue?

  2. Yana
    Yana avatar
    5025 posts

    Posted 24 Feb 2010 Link to this post

    Hello Mark,

    You should only add the custom control on every postback, not the whole node - in this way the events will be fired as expected. I suggest you set some Value to this node and then use this Value to find it and add the control to it.

    If you have any difficulties with the approach, please write to us again.

    Kind regards,
    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. Steven Lugovsky
    Steven Lugovsky avatar
    5 posts
    Member since:
    Mar 2010

    Posted 14 Apr 2010 Link to this post

    Out of curiousity - how did you accomplish this in the end? In which event did you readd the control to the node?

    Im trying to accomplish something similar and have noticed that if I add the control to the PageLoad event, I lose the viewstate.  If I try to add it to OnInit, the node isnt accessible yet so you have to add another node...


    Steve Lugovsky

    *EDIT* Nevermind ! this *does* work in the Page_load, my control ID was a victim of the ol' off-by-one error :P

  4. Chief
    Chief avatar
    5 posts
    Member since:
    Jul 2010

    Posted 02 Jun 2011 Link to this post

    Can you give a specific example about this issue?

    i tried to add template control

    NodeTemplate template = new NodeTemplate(item.Description.Trim().Substring(0, 5), true);                template.InstantiateIn(node);
    class NodeTemplate : ITemplate
                private string binder;
                private bool flag;
                public NodeTemplate(string binder, bool flag)
                    this.binder = binder;
                    this.flag = flag;
                public void InstantiateIn(Control container)
                    Literal ltr = new Literal();
                    ltr.ID = "ltr";
                    if (flag)
                        ltr.Text = @"<Font color='Red' size='3px'>" + binder + "..." + "</Font>";
                        ltr.Text = @"<Font color='Black'>" + binder + "..." + "</Font>";
                    //ltr.DataBinding += new EventHandler(label1_DataBinding);

    in the page load. but after postback loosing text inside literal.... actually loosing literal
  5. Plamen
    Plamen avatar
    3079 posts

    Posted 07 Jun 2011 Link to this post

    Hello bülent,

    Try to do your logic in Page_Init instead in Page_Load.

    You can see a simple example at one of our help topics:

    Plamen Zdravkov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top