当前位置: 代码迷 >> ASP.NET >> asp.net 中怎么实现 实现从下至上的树状图
  详细解决方案

asp.net 中怎么实现 实现从下至上的树状图

热度:5510   发布时间:2013-02-25 00:00:00.0
asp.net 中如何实现 实现从上至下的树状图
-------------------------------------------
|                                         |                                         |
|                                         |                                         |
-------------------------------------------
|                     |                   |                     |                   |
|                     |                   |                     |                   |
-------------------------------------------
|           |         |         |         |           |         |         |         |
|           |         |         |         |           |         |         |         |
-------------------------------------------

类似上图
可以看出层级所属关系
如何根据数据库中读取出来的数据,用table来实现
字段:id     ,   name   ,     genid


------解决方案--------------------------------------------------------
转个90度用TreeView不行吗?
------解决方案--------------------------------------------------------
自己写一个递归,后台拼接table.
------解决方案--------------------------------------------------------
思路是两次循环
给每个要显示的数据确定层级,然后选个合适的class 标记
然后循环 输出
------解决方案--------------------------------------------------------
获取根节点的子节点,树形
SQL code
Create FUNCTION dbo.getChildren(@RootID int)RETURNS @ChildrenTb TABLE(ID int)AS    BEGIN    Insert @ChildrenTb(ID) select ID from mytable where ID=@RootID    while @@ROWCOUNT>0    begin    Insert @ChildrenTb(ID)     select B.ID from @ChildrenTb A,mytable B     where A.ID=B.genID and B.ID not in (select ID from @ChildrenTb)     end    RETURN    END
  相关解决方案