Home - Forums-.NET - FlyTreeView (ASP.NET) - Adding data items to child nodes

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

Adding data items to child nodes
Link Posted: 28-Mar-2007 08:33
I'm working with the databinding tabular sample code and am trying to add additional fields other than the ones displayed, but no luck.  It's being added both to the DataTable on the C# end and as this line of code on the ASP.NET end:

  

However, it doesn't seem to be working.  I'm not sure what I'm leaving out or doing wrong.


Thanks!
Link Posted: 28-Mar-2007 09:07
How do you use
FlyTreeView.ConvertTabularDataToHierarchical(..) method?

Here what you need to add and display Test column.

using System;
using System.Data;
using System.Web;
using System.Web.UI;

public partial class Demo_DataBinding_Tabular : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Create sample data
            DataSet dSet = new DataSet(\"DataBase\");
            DataTable dTable = new DataTable(\"Orders\");
            dSet.Tables.Add(dTable);

            dTable.Columns.Add(\"ID\");
            dTable.Columns.Add(\"OwnerID\");
            dTable.Columns.Add(\"Title\");
            dTable.Columns.Add(\"Selected\");
            dTable.Columns.Add(\"Test\");

            // Add nodes (OwnerID is null for root nodes)
            dTable.Rows.Add(new object[] { 1, null, \"Developer Tools\", false, \"TestText\"});
            dTable.Rows.Add(new object[] { 2, 1, \"Spices.Net\", true, \"TestText\" });
            dTable.Rows.Add(new object[] { 3, 1, \"Spices.Obfuscator\", false, \"TestText\" });
            dTable.Rows.Add(new object[] { 4, 1, \"Spices.Decompiler\", false, \"TestText\" });
            dTable.Rows.Add(new object[] { 5, null, \".Net Controls\", false, \"TestText\" });
            dTable.Rows.Add(new object[] { 6, 5, \"FlyGrid.Net\" });
            dTable.Rows.Add(new object[] { 7, 5, \"FlyTreeView for ASP.NET 1.1\", false, \"TestText\" });
            dTable.Rows.Add(new object[] { 8, 5, \"FlyTreeView for ASP.NET 2.0\", true, \"TestText\" });


            // Call FlyTreeView.ConvertTabularDataToHierarchical method to convert into hierarchical datasource
            IHierarchicalEnumerable hierarchicalData =
                NineRays.WebControls.FlyTreeView.ConvertTabularDataToHierarchical(dSet, \"Orders\", \"ID\", \"OwnerID\");

            // Bind the treeview
            flyTreeView.DataSource = hierarchicalData;
            flyTreeView.DataBind();

        }

    }

}


So Test column will be shown when using


Also why do you need to use Depth attribute? It is zero-based value that filters nodes by level (also zero-based). So in your case this node binding will not work for root nodes.
Link Posted: 28-Mar-2007 09:21
That is precisely what I have and it doesn't work.  I even copy/pasted what you gave me to make sure that I got everything.
Link Posted: 28-Mar-2007 09:27
Maybe this will help to solve the mystery.  When I switch the two ASP.NET fields around, I see the test field but not the title:

                        
                        
                                                    CheckedField=\"Selected\" />
Link Posted: 28-Mar-2007 09:33
Also make sure to modify DataBindings collection so that code looks like:


    ...
    
    
        
    
    ...


And result:
Link Posted: 28-Mar-2007 09:35
[quote="Andrea"]Maybe this will help to solve the mystery.  When I switch the two ASP.NET fields around, I see the test field but not the title:

                        
                        
                                                    CheckedField="Selected" />

Yes, in your code treeview uses the first node binding for root nodes (level is 0):


That is why you do not get the second binding applied to root nodes.
Link Posted: 28-Mar-2007 09:36
Already have that, still no go:

                    BorderColor=\"Silver\" BorderWidth=\"1px\" Height=\"320px\" Width=\"280px\" Padding=\"1px\"
                    FadeEffect=\"True\" WideCell=\"True\" ExpandLevel=\"1\" CanBeSelected=\"false\" ContentClickCollapses=\"true\">

                    
                    
                        
                        
                                                    CheckedField=\"Selected\" />  
                                                                          
                    
                    
                        
                    
                
Link Posted: 28-Mar-2007 09:37
[quote="EvgenyT"][quote="Andrea"]Maybe this will help to solve the mystery.  When I switch the two ASP.NET fields around, I see the test field but not the title:

                        
                        
                                                    CheckedField="Selected" />

Yes, in your code treeview uses the first node binding for root nodes (level is 0):


That is why you do not get the second binding applied to root nodes.


If I remove the depth tag, I get the Title but not the Test.
Link Posted: 28-Mar-2007 09:42
Move

to top of the list.
Link Posted: 28-Mar-2007 09:43
Then everything, nodes included, are the value for Test.