我想做成这种效果 
姓名 张三 李四 王五 
年龄  25   26   27 
gridview不能这样横向显示 
DetailsView可以横向却只能显示一条记录 
用dataList的话不表头又不横向显示,在表单的上边显示,不知道怎么设定成横向 

解决方案 »

  1.   

    dataList罗,第一条记录放标题就可以了。不过如果是为了显示,自己写个 Table 不就更方便
      

  2.   

    这个最好还是自己构造table来做
      

  3.   

    datalist 可以的,repeatDirection为Horizontal
      

  4.   

    datalist  
    repeatDirection  =Horizontal
      

  5.   

    表头是可以new出来的使用datalist可以解决
      

  6.   

    自己在datalist里写一个table不就解决了吗,这样数据绑定的时候也容易
      

  7.   

    lz说的是行变列的问题吧?
    1.sql 2005直接支持行变列的数据集输出;
    2.sql 2000里自己写行变列的sql语句输出数据集
    3.也可以定义一个datatable,不过行数太多的话这样的效率很慢对于方法2,可以写个类似如下的行列转换sql——
    set nocount on
    SET QUOTED_IDENTIFIER OFF 
    SET ANSI_NULLS ON 
    declare @begin varchar(50),@end varchar(50)
    set @begin='2006-07-01'
    set @end='2006-07-24'
    declare @lSql varchar(2000),@lSql2 varchar(8000) --生成交叉表的SQL语句。
    declare @lItemID varchar(20)
    declare Items scroll cursor for
    select ServiceID from dbo.Students--假设的表
    where feetype=1
    order by ServiceID
    open Items
    select @lSql="select [head]='姓名'"
    select @lSql2="select [head]='年龄'"
    fetch first FROM Items INTO @lItemID
    while @@fetch_status=0
    Begin
    select @lSql = @lSql + ",[" + @lItemID + "]='" + @lItemID + "' "
    select @lSql2 = @lSql2 + ",[" + @lItemID + "]= max(case sname when '" + @lItemID + "' then convert(varchar(10),pv) else '0' end)"
    fetch next FROM Items INTO @lItemID
    End
    close Items
    deallocate Items
    select @lSql2=@lSql2+" from (select pv=count(recordid),sname from dbo.StudentsViewLog where viewtime>'"+@begin --假设的表
    +"' and viewtime<'"+@end+"' group by sname) as r group by day order by [head] "
    print (@lSql+" union all " + @lSql2)
    exec (@lSql+" union all " + @lSql2)打印出来后的sql就是——select [head]='姓名',[张三]='张三' ,[李四]='李四' ,[王五]='王五' 
    union all 
    select [head]='年龄',[张三]= max(case sname when '张三' then convert(varchar(10),pv) else '0' end),
    [李四]= max(case sname when '李四' then convert(varchar(10),pv) else '0' end),
    [王五]= max(case sname when '王五' then convert(varchar(10),pv) else '0' end) 
    from
    (select pv=count(recordid),sname from dbo.StudentsViewLog 
    where viewtime>'2006-07-01' and viewtime<'2006-07-24' group by sname
    ) as r 
    order by [head]