fill tree recursivly with data from database


J

Junky

Hi folks,

I guess I need a little help on this one.
I'm developing a web application using the TreeView object from the
WebControls (System.Web.UI.WebControls). Hierarchical data are read
from the database through a stored procedure. They have the following
stucture:

Name id level
AE 500100 3
AF 500200 3
AE A 500110 4
AE B 500120 4
AF A 500210 4
AE AA 500111 5
AE AB 500112 5

and so on...

so the id tells me what the parent is.

The tree should now look like this:

- rootNode
|
+ AE
|
+-AE A
| |
| |- AE AA
| |- AE AB
|
+-AF
| |
| |- AF A

I seem to have some problems with an recursive algorithm, so could
anybody give me a code snippet or something to get me on the right
way?
I've tried using the Tenary Search Tree Dictionary
(http://www.codeproject.com/csharp/tst.asp), but yet haven't found the
right thing.

Thanks in advance,
Junky ;-)
 
Ad

Advertisements


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

Top