Treeview problem, all nodes coming out as child

Last post 10-10-2007 11:52 AM by StrangerMike. 1 replies.

Sort Posts:

  • Treeview problem, all nodes coming out as child

    10-09-2007, 12:44 PM
    • Participant
      1,937 point Participant
    • StrangerMike
    • Member since 08-21-2003, 12:16 PM
    • B.C. Pa
    • Posts 1,076

    Hello,

    I am trying to work with my first treeview. When the page displays all of the nodes (parents and child) are displayed as Child nodes.

    I found an example of dynamically adding nodes, but on one particular line I get an error where they obviously do not. How do I differentiate between parents and children?   (below is a code snipet)

    Dim pNode As TreeNode

    Dim pChild As TreeNode

    ...

            pNode = New TreeNode()
            pNode.Text = DW                       'DW equal to parent text
            ApWireT.Nodes.Add(pNode)        'ApWireT is the name of the treeview control

            For i = 0 To 20                                          ' Loop through setting up child nodes
                If Mid(ApTab(i), 1, 2) = "ZA" Or Mid(ApTab(i), 1, 2) = "ZB" Then
                    SearchSub = "Z0"
                Else
                    SearchSub = Mid(ApTab(i), 1, 2)
                End If

                pChild = New TreeNode()
                pChild.Text = Mid(ApTab(i), 4, 50)
                ApWireT.Nodes.Add(pChild)

    The example code I have shows the line directly above as:    pNode.Nodes.Add(pChild), but I get an error stating "Nodes is not a member of 'System.web.ui.webcontrols.treenode".   

     Can anyone help?

    Thanks

     

    Thanks
  • Re: Treeview problem, all nodes coming out as child

    10-10-2007, 11:52 AM
    Answer
    • Participant
      1,937 point Participant
    • StrangerMike
    • Member since 08-21-2003, 12:16 PM
    • B.C. Pa
    • Posts 1,076

    in 2005 the answer was using this to add the child nodes:    pnode.ChildNodes.Add(pChild)

    Thanks
Page 1 of 1 (2 items)