Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
100
Moving Nodes Between WebDataTree's
posted

I'm currently working on a application that uses the WebDataTree to display groups as nodes that have child nodes.  My goal is to be able to move the parent nodes from one tree to another and vice versa.  I'm running into an issue where after a node is moved around several times the node basically goes blank.  Essentially I am moving one DataTreeNode object from one tree to another then back again.  I have attached screen shots to show what is happening.

Before:

 

After:

 

I am not exactly sure what is causing the node to render empty.  I am moving the nodes on the server side and am using full post backs.

Here's a code snippet:

Add:

 

    Protected Sub btnAdd_Click(ByVal sender As ObjectByVal e As System.EventArgsHandles btnAdd.Click
        ' Make sure we have a valid WG selected
        If wdtAllWg.SelectedNodes.Count > 0 Then
            ' Get selected nodes to add
            For Each wgNode As DataTreeNode In wdtAllWg.SelectedNodes
                ' Reset node and add to trees
                With wgNode
                    .Selected = False
                    .Expanded = False
                End With
                wdtEmpWg.Nodes.Add(wgNode)
                wdtCopyEmpWG.Nodes.Add(wgNode)

                ' Remove the node from the Dept WG's tree
                wdtAllWg.Nodes.Remove(wgNode)
            Next
        End If
    End Sub

Remove:

    Protected Sub btnRemove_Click(ByVal sender As ObjectByVal e As System.EventArgsHandles btnRemove.Click
        ' Make sure we have nodes selected to remove
        If wdtEmpWg.SelectedNodes.Count > 0 Then
            For Each wgNode As DataTreeNode In wdtEmpWg.SelectedNodes
                ' Collapse the node and remove it from emp WG trees
                With wgNode
                    .Selected = False
                    .Expanded = False
                End With

                ' Add WG back to the Dept WG tree
                wdtAllWg.Nodes.Add(wgNode)

                ' Remove the WG from the emp WG trees
                wdtEmpWg.Nodes.Remove(wgNode)
                wdtCopyEmpWG.Nodes.Remove(wgNode)
            Next
        End If
    End Sub

I'm wondering is something is getting thrown off when moving the DataTreeNode from one tree to another. I am at a loss right now though.