Home - Forums-.NET - FlyTreeView (ASP.NET) - Maybe I'm just dense!

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

Maybe I'm just dense!
Link Posted: 11-Apr-2007 08:32
I am new to this control ... have done a lot of SQL to Treeview and RadTree but I like what I see in the features etc. here BUT I'm having an awful time getting the nodes to show the details of each item.

A simplified version of my code is below. I am getting something because the tree is poulating with the correct number of nodes and the right 'parent' / 'child' relationship but every node is:
    system.data.datarowview

I seem to be populating data to hierarchicalData if I break into it.

I've tried both the dataset and table arguments in the heirarchy gadget ... same result.

I realy want to use this control but I've lost a day and I can't afford another one ... please helpppppp!

Dim dbCon As SqlConnection dbCon = New SqlConnection(ConfigurationManager.ConnectionStrings(\"XXX\").ConnectionString)

Dim cmd_sp As New SqlCommand(\"XXX\", dbCon)
cmd_sp.CommandType = CommandType.StoredProcedure

Dim adapter As SqlDataAdapter = New SqlDataAdapter()
adapter.SelectCommand = cmd_sp

Dim ds As DataSet = New DataSet()
adapter.Fill(ds)

Dim dSet As DataSet = New DataSet
Dim dTable As New DataTable(\"Nodes\")
dSet.Tables.Add(dTable)
dTable.Columns.Add(\"ItemID\")
dTable.Columns.Add(\"ParentID\")
dTable.Columns.Add(\"Name\")

adapter.Fill(dSet)

Dim dbRow As DataRow
            For Each dbRow In ds.Tables(0).Rows

                dTable.Rows.Add(New Object() {dbRow(\"ItemID\").ToString(), dbRow(\"Parentid\").ToString(), dbRow(\"Name\").ToString()})

            Next dbRow

            Dim hierarchicalData As IHierarchicalEnumerable = NineRays.WebControls.FlyTreeView.ConvertTabularDataToHierarchical(dTable, \"ItemID\", \"ParentID\")

            FlyTree.DataSource = hierarchicalData
            FlyTree.DataBind()
Link Posted: 11-Apr-2007 10:25
Please edit the FlyTreeView.DataBindings collection.

Create a databinding like the following (the code is taken from ASPX markup)




    ...
    
        
    


This will make treeview to popupate Text property of node using the Name property/attribute/field of data source item.
Link Posted: 12-Apr-2007 00:36
Thanks for the response

I actually had it at one point and broke it wondering why it only worked for the first level or two ... then rellized that I have to actually specify and bind each 'level'.
As I go forward the end users tree may have any  number of levels.
Can I (and how or is there a demo of) create the bindings in code?

My simple code below doesn't show the recusive stuff but I'd like to create a new 'level' in the bindings only if it's needed.

Suggestions
Link Posted: 12-Apr-2007 07:29
Yes, you can simply create bindings within the code.

Like this

FlyNodeBinding binding = new FlyNodeBinding();
binding.TextField = \"Name\";

flytreeview.DataBindings.Add(binding);