ASP.NET TreeView:使用 TreeView.TreeNodePopulate 时无法获取 TreeNode.Parent 和 TreeNode.ChildNodes
当用户第一次展开父节点时,我正在填充 TreeView
控件的节点,使用按需填充,如 ASP.NET:如何创建可扩展空树节点。填充过程运行良好。
问题是,当我尝试获取 TreeNode.Parent
时,即使 TreeNode
不是根节点,我也会得到 null 。另外,即使指定的 TreeNode 有一些子节点,TreeNode.ChildNodes
也会返回一个空集合...
对此有解释吗?并且,我能做些什么来解决它?
谢谢。
I am populating a TreeView
control's nodes at the moment user expands the parent node - the first time - using populate on demand as described in ASP.NET: How to Create an Expandable Empty TreeNode. The population process works fine.
The problem is when I try to get the TreeNode.Parent
I get a null even if the TreeNode
was not a root node. Also, TreeNode.ChildNodes
returns an empty collection even if there were some child nodes for the specified TreeNode
...
Is there an explanation for this? And, what can I do to solve it ?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的用户已选择根父节点,则下面的代码示例应该可以使用数据集合填充树:
protected void ParseTreeNodes(object sender, System.Web.UI.WebControls.TreeNodeEventArgs e)
我添加了额外的一行如果您的父节点有问题或知道
Nodes
集合中的特定值,请编写代码来检查树视图中的当前节点。If your user has selected the root parent node, this code example below should work to populate the tree using a collection of data:
protected void ParseTreeNodes(object sender, System.Web.UI.WebControls.TreeNodeEventArgs e)
I added an additional line of code to inspect the current nodes in the treeview if you are having an issue with the parent node or knowing the specific values in the
Nodes
collection.