help with an ordered list

K

Kevin

hi everyone. i'm trying to write asp to build an ordered list from a
database table. i'm running into issues with place holding.

here's an example of the data from the table..

id | parentID | file
1 | 0 | index.asp
2 | 1 | sub.asp
3 | 2 | subsub.asp
4 | 1 | sub2.asp


basically the way i have it, the parentID relates to the id of the list
item it should be located under. ie.

index.asp
sub.asp
subsub.asp
sub2.asp

and so on...

any idea how to get this kind of output to create a list like this?

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
A

Alan Howard

Look at coding a recursive routine. Basically pick up the records with no
parent node (ParentID IS NULL) - they're your top level nodes. Iterate
through them and call GetChildNodes (NodeID) where NodeID is the ID of the
node you're currently processing. Process each node (display it) and then
call GetChildNodes (NodeID) for that one, etc. Basically you're trying to do
a depth-first-search. You can use the depth of the recursion to provide help
with the indentation/formatting etc. Be careful though, these routines can
be expensive so optimise your code depending on your requirements.

Alan
 
C

Chris Hohmann

Kevin said:
hi everyone. i'm trying to write asp to build an ordered list from a
database table. i'm running into issues with place holding.

here's an example of the data from the table..

id | parentID | file
1 | 0 | index.asp
2 | 1 | sub.asp
3 | 2 | subsub.asp
4 | 1 | sub2.asp


basically the way i have it, the parentID relates to the id of the list
item it should be located under. ie.

index.asp
sub.asp
subsub.asp
sub2.asp

and so on...

any idea how to get this kind of output to create a list like this?

In addition to Alan's suggestion you may also want to consider using XSL to
transform the link array (edge set) into a hierarchical tree. Here's an
example:

http://groups.google.com/[email protected]

HTH
-Chris Hohmann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top