help with an ordered list

Discussion in 'ASP General' started by Kevin, Jun 3, 2004.

  1. Kevin

    Kevin Guest

    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!
     
    Kevin, Jun 3, 2004
    #1
    1. Advertising

  2. Kevin

    Alan Howard Guest

    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

    "Kevin" <> wrote in message
    news:e2dqu$...
    > 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!
     
    Alan Howard, Jun 4, 2004
    #2
    1. Advertising

  3. "Kevin" <> wrote in message
    news:e2dqu$...
    > 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/groups?selm=

    HTH
    -Chris Hohmann
     
    Chris Hohmann, Jun 4, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Newbie
    Replies:
    1
    Views:
    536
    Andrew Thompson
    Apr 7, 2004
  2. Arvind Ganesan

    ordered list (OL) tag with tables

    Arvind Ganesan, Sep 6, 2003, in forum: HTML
    Replies:
    10
    Views:
    10,590
    Nico Schuyt
    Sep 6, 2003
  3. Replies:
    3
    Views:
    2,206
  4. Replies:
    3
    Views:
    3,596
    Toby Inkster
    Apr 5, 2006
  5. DL

    Ordered list inside ordered list

    DL, Nov 9, 2009, in forum: Javascript
    Replies:
    6
    Views:
    335
    Dr J R Stockton
    Nov 21, 2009
Loading...

Share This Page