Protected Sub PopulateAddNode(ByVal ID As String, ByVal TN As TreeNode)
Dim newNode As TreeNode
Dim DV As DataView = New DataView(objDT)
DV.RowFilter = "PARENT_ID=" + ID
Dim dvRow As DataRowView
For Each dvRow In DV
newNode = New TreeNode
newNode.Text = dvRow.Item("ID").ToString & " " & dvRow.Item("NAME_LOCAL").ToString
newNode.Value = dvRow.Item("OID")
newNode.NavigateUrl = "javascript:funOnTreeNodeClick(this,'" & newNode.Value & "','" & newNode.Text & "')"
TN.ChildNodes.Add(newNode)
'再用本身來繼續添加自己的子結點
'PopulateAddNode(dvRow.Item("ID").ToString, newtn)
Next
End Sub
用它,可以添加任意層,關鍵是你自己去控制。