aspxtreelist默认情况下如何设置选择节点(VB)

时间:2012-03-18 02:34:58

标签: vb.net tree nodes treenode treelist

我正在使用visual basic,这是我第一次使用treelist。有关如何在aspxtreelist中设置节点的任何建议吗?

我想根据sql数据库在treelist中设置节点。

架构:

SQL数据库

  

| id ---- partnerID   |

     

| 1 ---- 2 |

     

| 2 ---- 3.2   |

     

| 3 ---- 4 |

Treelist

该树的值为2,2.1,2.2,3,3.1,3.2,4,5

  

| partnerID ---命令|

     

| 2 --- + |

     

| 2.1 --- + |

     

| 2.2 --- + |

     

| 3 --- + |

     

| 3.1 --- |

     

| 3.2 --- + |

     

| 4 --- |

     

| 5 --- |

'+'作为节点

当我加载页面时,我希望树状列表具有默认选择节点:2,2.1,2.2,3,3.2

我不知道必须使用什么属性。

1 个答案:

答案 0 :(得分:1)

我解决了我的问题。这里是我创建的答案:

    Dim iterator As TreeListNodeIterator = tree1.CreateNodeIterator()
    Dim node As TreeListNode
    Dim foundRow As DataRow
    Do While Not (_database Is Nothing)
        node = iterator.GetNext()
        If node Is Nothing Then
            Exit Do
        End If
        foundRow = _database.Rows.Find(node.Key)
        If Not (foundRow Is Nothing) Then
            node.Selected = True
        End If

    Loop

_database是一个数据表,我用它来收集数据库中的值。