可能重复:
Treeview from sql table
我正在使用下面的SQL表,其中包含三列id,parentid和name ..我必须在树视图中显示它:
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
如果有人知道,请帮帮我。
我希望输出为
观
- overcast
- yes
- rainy
- wind
- strong
- no
- weak
- yes
-sunny
- humidity
-high
-no
-normal
-yes
只有一个根节点。然后是子节点和子子节点......
答案 0 :(得分:0)
编写一个程序来从表中读取构造一个n-ary树并在预先遍历遍历中打印。
答案 1 :(得分:0)
如果您有一组行,则可以遍历该集合并以递归方式将每个项目添加到树视图中。