首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

在页面中怎么分组显示

2012-09-07 
在页面中如何分组显示?-----------IDName1b1a1c2d2e2f----------从数据库查出是这个样子的,怎么在页面显示

在页面中如何分组显示?
-----------
ID Name
1 b
1 a
1 c
2 d
2 e
2 f
----------
从数据库查出是这个样子的,怎么在页面显示成
ID name 
1 a;b;c;
2 d;e;f;

我用的是DataList,<%#Eval(name)%>我在页面是这么绑定的。 后台是DataSource= 查询方法。

求教如何才能实现上面那个样子显示,真是不知道怎么做了


[解决办法]
方式一:

SQL code
select b.id,    (case when b.a is not null then b.a +';' else '' end) +     (case when b.b is not null then b.b +';' else ''  end) +    (case when b.c is not null then b.c +';' else ''  end) +    (case when b.d is not null then b.d +';' else ''  end) +    (case when b.e is not null then b.e +';' else ''  end) +    (case when b.f is not null then b.f +';' else ''  end) name from(select id,    max(case name when 'a' then name else null end) a,    max(case name when 'b' then name else null end) b,    max(case name when 'c' then name else null end) c,    max(case name when 'd' then name else null end) d,    max(case name when 'e' then name else null end) e,    max(case name when 'f' then name else null end) ffrom tb_user_info group by id) b 

热点排行