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

Bind linqdatasource to TreeView

4 Answers 65 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Zeyad
Top achievements
Rank 1
Zeyad asked on 15 Mar 2011, 07:14 AM
Hello,

I'm new to ASP.NET programming, so please bare with me. 

I have a linqdatasource that is returning a table such as:

Show Season# Episode#
foo 1 1
foo 1 2
foo 1 3
foo 2 1
foo  2 2
bar 1 1
bar 1 2

I want to represent this table in a TreeView with expand/collapse nodes such as:

foo
Season 1
Episode 1
Episode 2
Episode 3
Season 2
Episode 1
Episode 2
bar
Season 1
Episode 1
Episode 2

How do I accomplish this scenario? 

Thanks,
Zeyad

4 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 17 Mar 2011, 03:32 PM
Hi Zeyad,

What you need is binding to hierarchical data, you could check this article here explaining how to do achieve it.

Best wishes,
Dimitar Terziev
the Telerik team
0
Zeyad
Top achievements
Rank 1
answered on 17 Mar 2011, 04:38 PM
Thanks for the reply. The article assumes a certain structure within the database. The sample table I mentioned below does not seem to fit this type of structure. Do I have to programmatically change my database table to match the hierarchical table that TreeView expects? If so, how do i do that? 
0
Zeyad
Top achievements
Rank 1
answered on 29 Mar 2011, 05:08 AM
Any thoughts?
0
Dimitar Terziev
Telerik team
answered on 31 Mar 2011, 04:11 PM
Hi Zeyad,

To our regret you won't be able to bind the RadTreeView directly to your existing database. 
You should query first your "shows" and add them to the RadTreeView node collection.
Then for each "show" node you should get the corresponding "seasons" and then again apply the same procedure for the "episodes".

All the best,
Dimitar Terziev
the Telerik team
Tags
TreeView
Asked by
Zeyad
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Zeyad
Top achievements
Rank 1
Share this question
or