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

RadTreeNode.Controls preserving ViewState

1 Answer 56 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
John Spinney
Top achievements
Rank 1
John Spinney asked on 07 Jul 2010, 02:27 PM
I am using RadTreeView with an ObjectDataSource containing objects that require different user controls that will fire change events be added to the RadTreeNode.Controls on OnDataBound.  The node controls collection does not appear to be included in the viewstate, and if not re-added on every postback the viewstate matching error occurs.  If the controls are recreated on a change postback, the originating control event does not fire.  Is there a set way to preserve the node controls to keep the viewstate happy and guarantee the firing of change events?  These user controls contain simple labels, dropdowns and text boxes etc.
Thanks.

1 Answer, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 12 Jul 2010, 01:37 PM
Hi John Spinney,

All dynamically created controls need to be recreated on every post back. This is a must since the View State is only persisting state and it's not recreating the controls.

The best way to add controls to the nodes of the RadTreeView is to create Templates which encapsulate these controls.

Here is an article explaining how to create and apply dynamic templates in RadTreeView: http://www.telerik.com/help/aspnet-ajax/tree_templatesruntime.html

About the events over the controls in the template:
- The events should fire even if the controls are in a template, but the only problem here is that the handler for each event, will be only 1 (if the template is applied multiple times, then multiple controls will have the same handlers assigned).

Hope this is helpful for you and if you need some more help, please feel free to contact with us again!


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
John Spinney
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question
or