Rank: Newbie Groups: Member
Joined: 9/29/2009 Posts: 5
|
Hi all, I'm new in this treeview thing. And I have a problem !!
I have a large Treeview, and I want to cache the Treeview in a web page, just so that on e.g postback I don't have to populate the treeview again. I can cache the Treeview, but when I cast it back it is blank. No treeview is displayed, but in debug, I can see that alle the Nodes are there. This is possible not the correct way, can anybody help ?
Code behind: Dim myTree As EO.Web.TreeView If Not (CType(Cache.Get("myNode"), EO.Web.TreeView) Is Nothing) Then
myTree = CType(Cache.Get("myNode"), EO.Web.TreeView) Try 'TreeView1 is the treeview on webpage TreeView1 = myTree
Catch ex As Exception teststring = " error: " + ex.Message
End Try
Else 'This creates a very complexed treeview. createTreeviewTest(False) Cache.Insert("myNode", TreeView1) End If
asp.net: <eo:TreeView ID="TreeView1" runat="server" Height="999px" Width="210px" SingleExpandMode="AllLevels" EnableViewState="False" StateCookieName="myTreeKage" EnableKeyboardNavigation="True" AutoCheckParent="True"> <LineImages PlusMinusOnly="False" ImageWidth="12" /> <LookNodes> <eo:TreeNode ItemID="_Default" RaisesServerEvent="True" > </eo:TreeNode> </LookNodes> </eo:TreeView>
Regards, Torben
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
No. You can't cache the TreeView that way. Assigning TreeView1 another value points TreeView1 to the TreeView object in your memory. It does not replace/rebuilt the TreeView in your page.
If you do not wish to populate the TreeView every time, you can load the data into a DataSet/DataTable (depending on how you populate it originally), then place that DataSet/DataTable object in your cache. You will still be populating the TreeView from the cached DataSet/DataTable object every time. But you only fill the DataSet/DataTable from your DB once.
Thanks!
|
Rank: Newbie Groups: Member
Joined: 9/29/2009 Posts: 5
|
Hi, Thanks for your fast reply. Okay, I just hoped for the quick solution (-: Regards, Torben
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
You are welcome. Let us know if you have any other questions!
|