Home - Forums-.NET - FlyTreeView (ASP.NET) - Bug in FlyTreeView.DataBind() and population of FlyNodeType?

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Bug in FlyTreeView.DataBind() and population of FlyNodeType?
Link Posted: 07-Feb-2007 09:16
Hi -

I am working on a project in which I have two FlyTreeViews on a page.  One represents the source and the other represents the target.  You can drag nodes from the source tree to the target tree to populate the target tree.  PostBackOnDropAccept=\"True\" is set on the target so that the nodes of the target tree are reconstructed with a content template to contain ImageButtons.  Each image button on the content template has its CommandArgument property set to .

All of this appears to work just fine... if I explore the FlyTreeView in debug mode in a QuickWatch window, the CommandArgument properties of all of the various nodes are set properly.

What doesn't appear to be working is:
The image buttons are used to move individual nodes up and down in the tree.  The image button has an OnClick event defined on it.  Then sender object which is passed as an argument to the OnClick event does not have the correct  property.  It contains a the value of another node in the tree.  In addition, navigating from the sender upwards through its container to the FlyTreeNode in a QuickWatch window shows that the FlyTreeNode is actually NULL.  It would appear that the wrong node is being sent to the event.  I imagine the containing node is null because we have rebound the target tree on the postback to a new dataset.  We have tried to explicitly call FlyTreeView.Nodes.Clear() prior to rebinding the target tree, but this has not had any effect.

Any help anyone could offer would be greatly appreciated.  Our code is included in the following posts.

Thanks,
Paul
Link Posted: 07-Feb-2007 09:20
source tree
=============
                
                                                           ContentClickCollapses=\"True\" DragDropMode=\"Copy\" ScrollLeft=\"0\" ScrollTop=\"0\">
                                                                     BorderWidth=\"1px\" ForeColor=\"White\" Padding=\"0px;2px;2px;0px\" />
                              
                                    
                                    
                                    
                                
                                
                                                                          ContentClickCollapses=\"False\">
                                                                          ContentClickCollapses=\"False\">
                                    
                                                                          ContentClickCollapses=\"False\">
                                    
                                
                            
                
Link Posted: 07-Feb-2007 09:21
target tree
==============
                
                                                                ContentClickCollapses=\"True\"
                                 DragDropAcceptNames=\"Form,Category,Question\"
                                 OnNodeInserted=\"TargetFormTree_NodeInserted\"
                                 OnNodeMoved=\"TargetFormTree_NodeInserted\"
                                 PostBackOnDropAccept=\"True\" ScrollLeft=\"0\" ScrollTop=\"0\">
                                                                BorderWidth=\"1px\" ForeColor=\"White\" Padding=\"0px;2px;2px;0px\" />
                              
                                    
                                    
                                    
                                
                                
                                                                          DragDropAcceptNames=\"Form,Category\" AutoApplyAtLevels=\"0\"
                                      ContentClickCollapses=\"False\">
                                                                          DragDropAcceptNames=\"Question\" AutoApplyAtLevels=\"1\"
                                      ContentClickCollapses=\"False\">
                                      
                                         '>
                                         '>
                                          ' OnClick=\"MoveCategoryUpButton_OnClick\"/>
                                          ' OnClick=\"MoveCategoryDownButton_OnClick\"/>
                                          ' OnClick=\"DeleteCategoryButton_OnClick\"/>
                                      
                                    
                                                                          DragDropAcceptNames=\"\" AutoApplyAtLevels=\"2\" ContentClickCollapses=\"False\" >
                                      
                                         '>
                                        '>
                                          ' OnClick=\"MoveQuestionUpButton_OnClick\"/>
                                          ' OnClick=\"MoveQuestionDownButton_OnClick\"/>
                                          ' OnClick=\"DeleteQuestionButton_OnClick\"/>
                                      
                                    
                                
                            
                
Link Posted: 07-Feb-2007 09:22
code behind
=================
    public void MoveCategoryUpButton_OnClick(object sender, EventArgs e)
    {
        String categoryId = ((System.Web.UI.WebControls.ImageButton)(sender)).CommandArgument;
        CategoryDataSource.UpdateParameters[\"CategoryID\"].DefaultValue = categoryId;
        CategoryDataSource.UpdateParameters[\"DirectionValue\"].DefaultValue = \"-1\";
        CategoryDataSource.Update();

        populateTargetForm();
    }

    public void populateTargetForm()
    {
         populate the target tree
        TargetFormTree.Nodes.Clear();
        DataView data = (DataView)TargetFormDataSource.Select(new DataSourceSelectArguments());
        if (data != null)
        {
            IHierarchicalEnumerable hierarchicalData =
                            NineRays.WebControls.FlyTreeView.ConvertTabularDataToHierarchical(data, \"ID\", \"ParentID\");
            TargetFormTree.DataSource = hierarchicalData;
            TargetFormTree.DataBind();
        }
    }
Link Posted: 08-Feb-2007 01:02
Paul,

As you can see the source code you've posted is truncated.
Anyway I've tried to create a page containing the same controls, but disconnected from your application implementation.

I've added a static XmlDataSource to create a source D&D tree. Anyway I miss something here.

Could you please help me and modify the page and its condebehind in order to make a test that will work in a disconnected (from your application) environment.

Here what I created:
http://download.9rays.net/treeview_asp.net_2/misc/pfreeman_test.zip

Please modify this code so it will have the same problems as your original page. You can send the results to flytreeview.asp[at]9rays.net. So we can debug it here and find the reason of the problem.


Thank you for cooperation.
Link Posted: 08-Feb-2007 01:39
Sure.  I will try and get something back to you by Monday.

Thanks,
Paul
Link Posted: 08-Feb-2007 04:37
There was a bug in FlyTreeNodeCollection.Clear() method. Solved.