ASP.NET TreeView and loading data on demand

后端 未结 2 1278
我寻月下人不归
我寻月下人不归 2021-01-19 19:36

Is there a way to force TreeView to load data on demand? In the other hand TreeView must load data only when a node is to be expanded. TreeVi

相关标签:
2条回答
  • 2021-01-19 20:25

    Three steps to do the trick:

    1 - Set the TreeView.ExpandDepth to 0. This eliminates the expansion of the added TreeNode objects in the TreeView and shows the expansion symbol [+] next to each TreeNode that has the TreeNode.PopulateOnDemand property set to true.

    2- Set the TreeNode.PopulateOnDemand to True for each branch TreeNode. When the TreeNode.ChildNodes collection is empty, the expansion symbol [+] will be showed only next to TreeNode objects that has TreeNode.PopulateOnDemand property set to true.

    3- Handle the TreeView.TreeNodePopulate event to poulate branch nodes on expansion. This event will be fired when a TreeNode - with the TreeNode.PopulateOnDemand set to true - has been expanded right before the TreeView.TreeNodeExpanded event gets fired.

    0 讨论(0)
  • 2021-01-19 20:36

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

    0 讨论(0)
提交回复
热议问题