ASP.NET TreeView and loading data on demand

Is there a way to get TreeView to load data on demand? On the other hand, TreeView should only load data when the extension is node. TreeView bound to a dataset that implements IHierarchyData .

+4
source share
2 answers

Three steps to do the trick:

1 - Set TreeView.ExpandDepth to 0. This eliminates the extension of the added TreeNode objects in the TreeView and displays the extension symbol [+] next to each TreeNode whose TreeNode.PopulateOnDemand property TreeNode.PopulateOnDemand set to true.

2- Set TreeNode.PopulateOnDemand to True for each TreeNode branch. When the TreeNode.ChildNodes collection TreeNode.ChildNodes empty, the extension character [+] will only be shown next to TreeNode objects whose TreeNode.PopulateOnDemand property TreeNode.PopulateOnDemand set to true.

3- Handle the TreeView.TreeNodePopulate event to bring the branch branches to the extension. This event will TreeNode if the TreeNode — with the TreeNode.PopulateOnDemand parameter set to true — has been extended before the TreeView.TreeNodeExpanded event TreeView.TreeNodeExpanded .

+9
source

Or you can just populate your tree based on various events available instead of loading the whole tree at once

0
source

All Articles