zoukankan      html  css  js  c++  java
  • GridView增加一个统计行的方法《原创》

    2008-07-27 16:11
    根据网上收集的资料,实现的方式比较多,推荐这种方式,比较好用! 
       private int sum1,sum2;  //全局变量
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
                   if (e.Row.RowType == DataControlRowType.DataRow)
            {
                sum1 += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Salery"));
                sum2 += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Count"));
            }
           
            // 合计
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[0].Text = "合计";
                e.Row.Cells[1].Text = sum1 .ToString();
                e.Row.Cells[2].Text = sum2 .ToString();
                e.Row.Font.Bold = true;  //设置当前行的字体变粗,醒目!
            }
        }
  • 相关阅读:
    shell脚本基础
    rtsp冷门解释
    C++基础之动态内存
    树莓派3安装ros
    Trie树
    [LeetCode]The Skyline Problem
    [LeetCode]Implement Trie (Prefix Tree)
    C++基础之适配器
    配置树莓派3的openwrt中的网络
    [LeetCode]Self Crossing
  • 原文地址:https://www.cnblogs.com/Golf9527/p/1558519.html
Copyright © 2011-2022 走看看