help with an ordered list

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin

    help with an ordered list

    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

    #2
    Re: help with an ordered list

    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" <kevin@NOSPAM0t ype.com> wrote in message
    news:e2dqu$YSEH A.1544@TK2MSFTN GP09.phx.gbl...[color=blue]
    > 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![/color]


    Comment

    • Chris Hohmann

      #3
      Re: help with an ordered list

      "Kevin" <kevin@NOSPAM0t ype.com> wrote in message
      news:e2dqu$YSEH A.1544@TK2MSFTN GP09.phx.gbl...[color=blue]
      > 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?[/color]

      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:



      HTH
      -Chris Hohmann


      Comment

      Working...