ASP.NET TreeView并根据需要加载数据 [英] ASP.NET TreeView and loading data on demand

查看:111
本文介绍了ASP.NET TreeView并根据需要加载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法强制 TreeView 按需加载数据?另一方面, TreeView 只有在要扩展节点时才能加载数据。 TreeView 绑定到实现 IHierarchyData 的数据集合。

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. TreeView is binded to a collection of data that is implementing IHierarchyData.

推荐答案

三个步骤来做窍门:

1 - 设置 TreeView.ExpandDepth 0 。这消除了 TreeView 中添加的 TreeNode 对象的扩展,并显示扩展符号 [+] 旁边每个 TreeNode ,它具有 TreeNode.PopulateOnDemand 属性设置为 true

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-设置 TreeNode.PopulateOnDemand 为每个分支 True TreeNode 。当 TreeNode.ChildNodes 集合为 时,扩展符号 [+] 将只显示在 TreeNode 具有 TreeNode.PopulateOnDemand 属性设置为 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-处理 TreeView。 TreeNodePopulate 事件来扩展分支节点。当 TreeNode - 将 TreeNode.PopulateOnDemand 设置为 true 时,此事件将触发 - 在 TreeView.TreeNodeExpanded 事件被触发之前已被扩展。

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.

这篇关于ASP.NET TreeView并根据需要加载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆