Binding a list for hierarchical data presentation

Posts   
 
    
ftuttle
User
Posts: 40
Joined: 10-Dec-2006
# Posted on: 16-Jan-2007 21:10:10   

I have 2 tables (Parent - Child with a 1:m relationship).

What is the best way to get the data to be presented in a Tree View control with the 1:m relationship?

I tried creating a list with both tables in the join, but I get a presentation with the Parent data in all records - the view was flattened out. I have a case where some parents may have 2 or more children and I am looking for a drill down method into the children (folder like view of the data).

Thanks

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 17-Jan-2007 02:47:07   

A few people have solved this in different ways. Some use the CTEs available in SQL 2005 others use precalc tables. Take a look at these two thread and post here if you have any questions.

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7862&HighLight=1

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3208&HighLight=1

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=4757&HighLight=1

ftuttle
User
Posts: 40
Joined: 10-Dec-2006
# Posted on: 17-Jan-2007 08:23:37   

Is the following an option for me to consider:

Use SQL 2005 to write out an XML string from a stored procedure ('FOR XML AUTO').

Use an LLBL object to grab the XML from the proc and then bind to that LLBL object in a control that will render a hierarchy using XML input?

thanks

Actually this would not work out so well as I would like the list to auto update when either parent or chile records are added, edited or deleted.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 17-Jan-2007 16:43:02   

I think it's better to use a Hashtable (at least from a performance point of view). And then you should handle yourself the addition & deletion of new nodes.