Click to See Complete Forum and Search --> : TreeView data


Toot
January 11th, 2008, 06:36 AM
I've got a DB with some hierarchical data in it which I want to represent using a TreeView. I'd like to store some data (i.e. an object) in each TreeNode so that I can load only when I need to and to cache the complex stuff (to minimise DB cursors, which don't perform very well).

TreeNode's Tag property has gone since I last tried this kind of thing, to be replaced by ... umm nothing???

So I've come up with deriving a storage class from TreeNode which contains a private member to store the object and an accessor property. But I'm faced with a problem - how do I get at it? In order to store it as a ChildNode in a TreeNode, it gets cast down to its base TreeNode class. But how do I get it back? I can't cast in the other direction!

How else is this achieved? I see I can set TreeNode.Value but then I need to be holding the data elsewhere so I can get at it, which seems a bit dumb. And where should I store it? A member on the page? In a session variable?

Any help greatly appreciated!
T