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

Failed to Load ViewState

4 Answers 111 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ed Tischofer
Top achievements
Rank 1
Ed Tischofer asked on 07 Aug 2008, 01:54 PM
I am currently adding controls to each node as I dynamically build the tree.  However, when the page posts back, I get the 'Failed to Load ViewState' exception.

Is there a special way that adding controls should be done in the latest version of the RadTreeView control?  Previously in the 'RadControls for ASP.NET (Classic)' suite, I was able to do what I am trying to accomplish, but I had to reload the controls for each node on a postback.

I appreciate any help regarding my issue.

4 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 07 Aug 2008, 02:04 PM
Hi Chris,

Have you considered using Templates? Here is how to add templates at runtime:
Adding and Editing Templates at Runtime

Greetings,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ed Tischofer
Top achievements
Rank 1
answered on 07 Aug 2008, 02:16 PM
Yes, I have considered it, but child nodes have a different set of controls then root nodes.  Additionally, I dynamically build the tree based on an XML document because certain child nodes receive a specific set of attributes that differs from the root nodes.  Given my scenario, do you think it will still work?  I originally tried using Templates for 'RadControls for ASP.NET (Classic)', but it did not work for me.
0
Veselin Vasilev
Telerik team
answered on 11 Aug 2008, 10:40 AM
Hi Chris,

You can have two different classes representing the templates for the root nodes and the child nodes.
Then in NodeBound event you can instantiate the appropriate class depending on the level of the node.
I have prepared a sample project for you. Please download it and give it a try.


All the best,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ed Tischofer
Top achievements
Rank 1
answered on 14 Aug 2008, 01:49 PM
Veskoni:

Thank you for you reply.  Using the Templates worked.  However, adding the controls without the templates would have worked too as long as I made sure they were added after all nodes were added to the tree.

Would you please explain why controls/templates cannot be added to tree nodes until the tree is fully built?

Thank you,

Chris
Tags
TreeView
Asked by
Ed Tischofer
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Ed Tischofer
Top achievements
Rank 1
Share this question
or