以编程方式在TreeView上扩展节点时为空值 [英] Null values when expanding nodes on a TreeView programmatically

查看:68
本文介绍了以编程方式在TreeView上扩展节点时为空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,

我目前正在我们公司的网站上工作,该网站由两组导航组组成.

第一组当然是 主菜单 垂直设置在页面左侧,第二组是 子菜单 水平设置在页面顶部.

主菜单 使用的是TreeView控件,而 子菜单 则通过简单的"html"

    Greetings,

    I am currently working on our company''s website that consists of two sets of navigational groups.

    The first group is of course the main menu set to the left side of the page vertically, and the second group is the sub menu set on top of the page horizontally.

    The main menu is using a TreeView control and the sub menu is setup in a simple "html"

      Protected Sub TreeView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.DataBound
              TreeView1.CollapseAll()
              Dim tn As TreeNode = TreeView1.SelectedNode
              tn.Expand()
              If tn.Parent IsNot Nothing Then
                  tn = tn.Parent
                  tn.Expand()
              End If
      
          End Sub



      现在我的问题是,当用户在 子菜单 中选择一个链接时,它具有一个 Null 值.扩展TreeView节点时,是否有更好的方法来执行此操作?我必须有一个不同于 主菜单 的单独的导航菜单吗?我喜欢 主菜单 的工作方式,并且不想更改它.任何类型的帮助都将是不胜感激的!

      谢谢



      Now my problem is when the user selects a link in the sub menu it has a Null value. Is there a better way to do this when expanding the TreeView nodes. I must have a separate navigation menu different from the main menu? I do like how the main menu is working and did not want to change it. Any type of help would be really appreciative!

      Thank you

      推荐答案

      如果使用的是ASP.NET链接按钮,则可以使用TAG属性存储树视图父节点ID/名称.在回发时,您可以使用标签内容来确定要扩展的树节点.

      如果不是这种情况,那么我认为它必须是一些javascript.您可以使用rel属性(如果使用html标签)来将父节点ID存储在其中.知道了id后,您就可以引发一个事件以崩溃并扩展节点.

      http://pushpontech.blogspot.co.uk/2007/06/client-side-expandcollapse-all-nodes.html [ ^ ]
      If you were using ASP.NET link buttons you could use the TAG attribute to store the treeview parent node Id / name. On postback you could use the tag contents to work out what tree node to expand.

      If this is not the case then I think it would have to be some javascript. You could use the (if using a html a tag) rel attribute to store the parent node id in it. Knowing the id you could then raise an event to collaps and expand the nodes.

      http://pushpontech.blogspot.co.uk/2007/06/client-side-expandcollapse-all-nodes.html[^]


      这篇关于以编程方式在TreeView上扩展节点时为空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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