之前用GridView直接绑定数据源显示,
后来客户要求,将最值(最大值、最小值、平均值、总值)也要显示在列表中。试问咋个做好一些那??
我想尝试在最后一页新增4列显示,但是怎么做?谢谢有经验的同志啊!

解决方案 »

  1.   

    是所有数据的最值,还是相对于行的最值,如果是所有数据的最值,用gridvie也可以,增加footer来显示。
      

  2.   

    在footer添加模板列
    <FooterTemplate>
        <asp:Label runat="server" Id="lbl1" Text="<%# A() %>" />
    </FooterTemplate>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 

        if (e.Row.RowIndex >= 0) 
        { 
            sum += Convert.ToDouble(e.Row.Cells[2].Text); 
        } 
        else if (e.Row.RowType == DataControlRowType.Footer) 
        { 
            e.Row.Cells[5].Text = "总和为:"; 
            e.Row.Cells[6].Text = sum.ToString(); 
            e.Row.Cells[3].Text = "平均值为:"; 
            e.Row.Cells[4].Text = ((int)(sum / GridView1.Rows.Count)).ToString(); 
        } 

      

  3.   

    <asp:Label runat="server" Id="lbl1" Text=" <%# A() %>" /> 
    是什么意思?你这个只能显示2个值?
      

  4.   

    这还要讲,当然是用Sql实现啦~,然后绑定一下就OK了,只要SQL写好一点就没问题了,简单的!
      

  5.   

    sql语句
      select a from table
      union
      select max(x) from table
      union
       ....
      执行后绑定GridView
    GridView模板列
      baidu搜索  72般绝技 有源码实现最值
     
      

  6.   

    我想把最值和记录放在gridview一起。 72般绝技我看了,但是只能显示每一页的,我想显示所有记录的。