TreeView not rendering nodes? Cacheing of a TreeView

Discussion in 'ASP .Net Web Controls' started by Per Salmi, Oct 15, 2003.

  1. Per Salmi

    Per Salmi Guest

    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
     
    Per Salmi, Oct 15, 2003
    #1
    1. Advertising

  2. Per Salmi

    Steve Drake Guest

    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
    "Per Salmi" <> wrote in message
    news:%23$...
    > 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
    >
    >
     
    Steve Drake, Oct 15, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J'son
    Replies:
    0
    Views:
    391
    J'son
    Apr 12, 2005
  2. roy anderson

    Images not cacheing in 2.0?

    roy anderson, Jan 31, 2006, in forum: ASP .Net
    Replies:
    8
    Views:
    434
    roy anderson
    Feb 1, 2006
  3. Replies:
    3
    Views:
    891
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Apr 19, 2006
  4. darrel

    Cacheing DB content

    darrel, May 30, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    721
    darrel
    May 30, 2006
  5. Thom Anderson

    Cacheing Business Objects

    Thom Anderson, Nov 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    412
    John Timney \(MVP\)
    Nov 26, 2006
Loading...

Share This Page