Home - Forums-.NET - FlyTreeView (ASP.NET) - Databinding FlyNodeSets

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

Databinding FlyNodeSets
Link Posted: 16-Sep-2005 00:23
I have built a single column DataTable (dt). The column is called "Col". The table has 17 rows, which are properly filled (separately checked). I'm trying to bind it to a FlyNodeSet (fns) doing the following:

fns.DataSource = dt;
fns.DataMember = "Col"; // probably useless, since we have a single column
fns.DataBind();


This FlyNodeSet is in an aspx page, which in turn is used as NodeSrc for a FlyTreeView. The above code is in the Page_Load() handler of the FlyNodeSet.

When I click to expand the node tied to the FlyNodeSet, everything goes fine until the DataBind executes; I then get the following error in an IE dialog box:
Error occurred:
Description: Error while parsing loaded data.
Details: The download of the specified resource has failed.


I guess I must be missing something in the process. Any hints ?

Thanks,
Pyt.
Link Posted: 17-Sep-2005 19:50
What do you have in
fns.Nodes collection after the DataBind() call?

Could you please debug it?
Link Posted: 18-Sep-2005 00:03
Did a bit more investigation. The Databind() actually throws an exception. The message I caught is:

DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name Key.


Does this ring a bell ? I'm not too familiar with DataSets, DataTables, etc..., so this kinda cryptic to me.

Thanks for the help you can provide.
Pyt.
Link Posted: 18-Sep-2005 20:36
Ok, now I understand.

Actually any datasource used with the treeview must be enumerable collection of dataitems.
Every dataitem has several obligatory properties.
For example Key and ParentKey fields.
You may also modify names of these fields in your datasouce before calling DataBind() like:

fns.DataFileds.Key="ID";
fns.DataFileds.ParentKey="ParentID";
fns.DataFileds.Text = "Name";
... and so on.

Anyway you should refer to the databinding example source code to understand the databinding techinque used within the FlyTreeView control (probably common to all the ASP.NET bindable controls).
Link Posted: 19-Sep-2005 03:21
hmmm, ok, got it ! I should be able to figure it out. Thanks for the help.

Pyt.