This is a migrated thread and some comments may be shown as answers.

Use ObjectDataSource in hierarchy

2 Answers 122 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jeremy Deckard
Top achievements
Rank 1
Jeremy Deckard asked on 03 Apr 2008, 04:44 PM
I have  generic List of objects (pages) each on has an ID and ParentID in an ObjectDataSource.  I have set the appropriate properties in the treeview but  all I get is a single level list not  a hierarchy as expected.

    <telerik:RadTreeView ID="RadTreeView1" runat="server" Skin="Vista" DataSourceID="dsPages" DataFieldID="PageID" DataFieldParentID="ParentPageID" DataTextField="Name" DataValueField="PageID" />

2 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 04 Apr 2008, 10:33 AM
Hi Jeremy Deckard,

Thank you for contacting Telerik Support!

Binding RadTreeView to a data source that implements IEnumerable, such as Array or ArrayList, creates a flat data structure. Only root items are created and there is no hierarchy.

More detailed information is available here: Binding to Array, ArrayList and Generic List

I believe that these two links will help you too:


I hope this helps.

Sincerely yours,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jason Clark
Top achievements
Rank 1
answered on 23 Jul 2008, 05:28 PM
Just an FYI, there is a more elegant way than the code sample posted by Telerik:

http://elegantcode.com/2008/04/06/aspnet-hierarchicaldatasourcet/

Only change that I found was in his HierarchyData class you need a property called name which returns  the name of the data item.   Now you have a generic way to deal with this problem.

Perhaps Telerik could post this instead/along with the other example, since this is much more reusable.

Cheers
Tags
TreeView
Asked by
Jeremy Deckard
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Jason Clark
Top achievements
Rank 1
Share this question
or