-2

Possible Duplicate:
Treeview from sql table

I am having SQL table like below with three columns id,parentid and name.. I have to show it in tree view:

id   parentid    name
1     NULL      outlook
2     1      overcast
3     1       rainy
4     1       sunny
5     2        yes
6     3        wind
7     4      humidity
8     6       strong
9     6        weak
10    7        high
11    8         no
12    9         yes
13   10          no
14   15         yes
15   7        normal

Please help me if any one knows....

I want output as

  • outlook

    - overcast
    
             - yes
    
    - rainy
           - wind
                - strong
                      - no
                - weak
                      - yes
    -sunny
           - humidity
    
                 -high
                       -no
                 -normal
                       -yes
    

There is only one root node.then comes child nodes and sub-child nodes like that..

Community
  • 1
  • 1
dhanya
  • 67
  • 1
  • 1
  • 4
  • one aspect of Stack Overflow is that once you post a question, if you have additional information, you can edit your original question. Opening a new one that is identical to your first is considered bad form. – NotMe Jul 20 '11 at 03:54

2 Answers2

0

Write a program to read from table construct a n-ary tree and print in pre-order traversal.

KaKa
  • 1,543
  • 12
  • 18
0

If you have a collection of rows you could just iterate through the collection and recursively add each item to your tree view.

tam
  • 1,583
  • 2
  • 13
  • 25