TreeNode objects inaccesible during postback

P

Phil H

Hi

Can anyone tell why the SelectedNode property of a TreeView is
sometimes inaccessible during a postback event?

I developed a small web application recently that features a TreeView.
The nodes are created programatically but the TreeView itself is
created at design time.

I also used a mulitview object and several views, the Tree being in one
of them. I found that I can access the tree during postback events so
long as it is generated by a control in the same view as the tree (i.e.
the host view set active) but if I switch to another view and then
process events from controls there the SelectNode property returns null
(or nothing in VB).

The curious thing is that the Tree is recreated in tact with the same
selected node when the view is re-activated, ie. it is preserved by
Viewstate. Yet I can access controls in other hidden views (e.g.label
objects) from the view containing the tree any time I like.

Has this got anything to do with the fact that the nodes are created
programatically?

I've had this sort of anxst before with VS2003. I get terribly confused
over what is preserved and what is not between postbacks.

I'd be very greatful to anyone who can shed some light on this.
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top