TreeView not rendering nodes? Cacheing of a TreeView

P

Per Salmi

I have a rather large TreeView in a web form. This is built from database
content.
What is the easiest way to store the TreeView NodeCollection so that I don't
have to build it again from the database when a new request for the same
page is performed?

I have tried storing the treeview object in an Application variable and
retrieving it checking that it is populated with nodes and then setting the
treeview object to use this retrieved treeview.

The page works but the tree is not rendered to the page.

Is there a way to refresh the treeview after setting the object in the
Page_Load event handler?

The code in the Page_Load event handler looks something like this:

if (Application["treeview"] == null) {
PopulateTreeView(); // This one fills the NodeCollection with content
Application["treeview"] = treeview1; //Store the treeview for future
reuse
} else {
treeview1 = (TreeView)Application["treeview"]; // Get the existing
treeview
}

I have checked that the Nodes list contains the expected nodes when the
treview is reused from the Application variable but why does it not render
the tree when the nodes are there?

/Per Salmi
 
S

Steve Drake

Why not cache the dataset? that's what I've done in the past and it works
well.

I would use Page.Cache and not the Application object as the Page.Cache will
get cleared if ASP.NET needs the resources (I think thats what the docs
say).

Steve
 

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,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top