M
Mike
I am trying to add a node under existing nodes, but making sure they don't
exist before putting adding it.
Here is my Code
Public Sub BuildTree()
.... above this, root nodes were added.
For Each dr In drs
Dim childnode As TreeNode = nTreeNode(dr("ROLE_DESC"),
dr("ROLE_ID"), dr("REL_ROLE_ID"))
Dim parentnode As TreeNode =
treeRoles.FindControl(dr("REL_ROLE_ID"))
If treeRoles.Nodes.Contains(childnode) = False Then
treeRoles.Nodes.AddAt(treeRoles.Nodes.IndexOf(parentnode),
childnode)
End If
Next
End Sub
Public Function nTreeNode(ByVal strText As String, ByVal strID As String,
ByVal strNodeData As Object) As TreeNode
Dim tn As New TreeNode
tn.Text = strText
tn.ID = strID
If IsDBNull(strNodeData) = False Then
tn.NodeData = strNodeData
Else
tn.NodeData = ""
End If
Return tn
End Function
I am trying to set parentnode as a reference to the parent node. However,
the FindControl method cannot be converted to a TreeNode type. Is there
another way to do this. This TreeView is bound to a database and all the data
is in one table. The table contain a primaryID (ROLE_ID) and
ParentID(REL_ROLE_ID), where the ParentID is the PrimaryID of the rows
parent.
ie
Table1
ROLE_ID REL_ROLE_ID
1
2 1
3 1
4
5
6 4
7 4
8 7
9 7
10 7
This table should produce the following tree
1
-- 2
-- 3
4
-- 5
-- 6
-- 7
-- -- 8
-- -- 9
-- -- 10
Thanks in advance.
exist before putting adding it.
Here is my Code
Public Sub BuildTree()
.... above this, root nodes were added.
For Each dr In drs
Dim childnode As TreeNode = nTreeNode(dr("ROLE_DESC"),
dr("ROLE_ID"), dr("REL_ROLE_ID"))
Dim parentnode As TreeNode =
treeRoles.FindControl(dr("REL_ROLE_ID"))
If treeRoles.Nodes.Contains(childnode) = False Then
treeRoles.Nodes.AddAt(treeRoles.Nodes.IndexOf(parentnode),
childnode)
End If
Next
End Sub
Public Function nTreeNode(ByVal strText As String, ByVal strID As String,
ByVal strNodeData As Object) As TreeNode
Dim tn As New TreeNode
tn.Text = strText
tn.ID = strID
If IsDBNull(strNodeData) = False Then
tn.NodeData = strNodeData
Else
tn.NodeData = ""
End If
Return tn
End Function
I am trying to set parentnode as a reference to the parent node. However,
the FindControl method cannot be converted to a TreeNode type. Is there
another way to do this. This TreeView is bound to a database and all the data
is in one table. The table contain a primaryID (ROLE_ID) and
ParentID(REL_ROLE_ID), where the ParentID is the PrimaryID of the rows
parent.
ie
Table1
ROLE_ID REL_ROLE_ID
1
2 1
3 1
4
5
6 4
7 4
8 7
9 7
10 7
This table should produce the following tree
1
-- 2
-- 3
4
-- 5
-- 6
-- 7
-- -- 8
-- -- 9
-- -- 10
Thanks in advance.