TreeView

K

kvicky

I am trying to load child nodes to a TreeNode in a TreeView in a
ASP.net web application.

The Treeview with parent nodes are loaded on a Page_load while doing
if( ! ISPostback ) and then in the Treeview event I am dynamically
trying to load the child nodes to the exisisting TreeView. The problem
is since the TreeView is being loaded on not a Postback, I am unable to
refer to any node in the TreeView event. Can anybody tell me how to
refer to the treeNode when it is loaded on not a postback.

Thanks
 
D

Dave Sexton

Hi,

Please correct me if I'm wrong. It seems that you want to load a TreeView control in the Page Load event only if the page has not
been posted back to the server but you want to handle some event on the TreeView control, which will only be raised when the page is
posted back to the server.

You have to create the TreeView if you want to access it's nodes, even on a post back, so make sure the TreeView is created every
time the Page is requested.

Also, you should add the TreeView to the Controls collection of its Parent Control before the Page's Load event is raised, not
during the Load event, if you want the TreeView to be able to use the ViewState. For this reason controls are commonly initialized
in the Page's Init event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top