zoukankan      html  css  js  c++  java
  • gridview 合计行实现

    1:首先给gridview添加ShowFooter="true" 属性

    2:在RowDataBound 实现数据合计

    protected override void OnMainGridRowDataBound(object sender, GridViewRowEventArgs e)     {        

    base.OnMainGridRowDataBound(sender, e);

     if (e.Row.RowType == DataControlRowType.DataRow)        

        {             

     clickcount += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "PVCount"));            

    ipconut += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "IPCount"));            

    amoutcount += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "AmountQR"));            

    talkcount += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "talkCount"));            

    ordercount += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "CountQR"));            

    shouamount += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "AmountQS"));            

    shoucount += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "CountQS"));

    }        

    else if (e.Row.RowType == DataControlRowType.Footer)        

    {            

    e.Row.Cells[0].Text = "合计";            

    e.Row.Cells[4].Text = clickcount.ToString();            

    e.Row.Cells[5].Text = ipconut.ToString();            

    e.Row.Cells[6].Text = amoutcount.ToString("0.00");            

    e.Row.Cells[7].Text = talkcount.ToString();            

    e.Row.Cells[8].Text = ordercount.ToString();            

    e.Row.Cells[9].Text = shouamount.ToString();            

    e.Row.Cells[10].Text = shoucount.ToString();            

    e.Row.Font.Bold = true;        

    }

        }

  • 相关阅读:
    Jdbc、Mybatis、Hibernate各自优缺点及区别
    java中的线程池原理
    JVN的理解
    "=="和 equals 方法究竟有什么区别?
    nginx基础之【study one】
    C#,WPF中使用多文本显示数据,并对其数据进行关键字高亮等操作
    C#、WPF中如何自定义鼠标样式
    SSM(Spring + Springmvc + Mybatis)框架面试题
    java基础面试题
    C#关于TreeView树在节点数较多时总是会出现闪烁的问题方法记录
  • 原文地址:https://www.cnblogs.com/EDSON/p/3096498.html
Copyright © 2011-2022 走看看