Hi-
I'm running this database query where the results will be used to
populate my treeview.
For Each drPA As DataRow In dsMasterList.Ta bles(0).Rows
iRoot = iRoot + 1
nRootNode = New TreeNode(drPA(0 ), iRoot, "", "", "")
nRootNode.Selec tAction = TreeNodeSelectA ction.Expand
tvMasterList.No des.Add(nRootNo de)
For Each drSubject As DataRow In
dsMasterList.Ta bles(1).Rows
If (drSubject(1) = nRootNode.Text) Then
iSub = iSub + 1
nSubNode = New TreeNode(drSubj ect(1), iSub, "",
"", "")
nRootNode.Child Nodes.Add(nSubN ode)
For Each drTopic As DataRow In
dsMasterList.Ta bles(2).Rows
If (drTopic(1) = nSubNode.Text) Then
iTopic = iTopic + 1
nTopicNode = New TreeNode(drTopi c(1),
iTopic, "", "", "")
nSubNode.ChildN odes.Add(nTopic Node)
End If
Next
'nSubNode.Expan d()
End If
Next
'tvMasterList.N odes.Add(nRootN ode)
'nRootNode.Expa nd()
Next
If I uncomment the expand functions, I can see that my code works
nicely, and the treeview is populated correctly. But it won't expand
or collapse! When I try it I get the following error in the IE
'debugger':
"Childnodes .0 is null or not an object"
I'm really lost here, any help will be greatly appreciated.
I'm running this database query where the results will be used to
populate my treeview.
For Each drPA As DataRow In dsMasterList.Ta bles(0).Rows
iRoot = iRoot + 1
nRootNode = New TreeNode(drPA(0 ), iRoot, "", "", "")
nRootNode.Selec tAction = TreeNodeSelectA ction.Expand
tvMasterList.No des.Add(nRootNo de)
For Each drSubject As DataRow In
dsMasterList.Ta bles(1).Rows
If (drSubject(1) = nRootNode.Text) Then
iSub = iSub + 1
nSubNode = New TreeNode(drSubj ect(1), iSub, "",
"", "")
nRootNode.Child Nodes.Add(nSubN ode)
For Each drTopic As DataRow In
dsMasterList.Ta bles(2).Rows
If (drTopic(1) = nSubNode.Text) Then
iTopic = iTopic + 1
nTopicNode = New TreeNode(drTopi c(1),
iTopic, "", "", "")
nSubNode.ChildN odes.Add(nTopic Node)
End If
Next
'nSubNode.Expan d()
End If
Next
'tvMasterList.N odes.Add(nRootN ode)
'nRootNode.Expa nd()
Next
If I uncomment the expand functions, I can see that my code works
nicely, and the treeview is populated correctly. But it won't expand
or collapse! When I try it I get the following error in the IE
'debugger':
"Childnodes .0 is null or not an object"
I'm really lost here, any help will be greatly appreciated.
Comment