- string sql = "";
- sql += " declare @sql varchar(8000)";
- sql += " set @sql = 'select [name] as ''名称'',mbz as ''目标值'' ,yjz as ''预警值'' ,zrr as ''责任人'',sum(type)/count(*) as ''达标占比'',sum(type)/count(*) as ''统计'','";
- sql += " select @sql = @sql + 'sum(case Convert(varchar(10),tims,121) when '''+n+''' then value else 0 end) as '''+n+'日'',sum(case Convert(varchar(10),tims,121) when '''+n+''' then id else 0 end) as ''--'','";
- sql += " from (select distinct top 32 tims as n from rjk where type=1 and left(timss,len(timss)-10)='2012-9' order by tims desc) as a";
- sql += " select @sql = left(@sql,len(@sql)-1) + ' from rjk where type=''1'' and left(timss,len(timss)-10)=''" + str + "'' group by [name],mbz,yjz,zrr'";
- sql += " exec(@sql)";
- cn.Open();
- SqlDataAdapter da = new SqlDataAdapter(sql.ToString(), cn);
- DataSet ds = new DataSet();
- cn.Close();
- da.Fill(ds);
- this.GridView1.DataSource = ds;
- GridView1.DataBind();
复制代码
用asp.net的GridView是可以显示的,效果如下图:
但用Gird同样的话,不可以显示数据以及表头,请问我可以用什么方式才可以正常显示呢?
|