Net Core教程

C#gridview尾部统计

本文主要是介绍C#gridview尾部统计,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
 protected void gridSettlement_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (dtSettlement != null && dtSettlement.Rows.Count > 0)
            {
                decimal sum = 0;
                for (int i = 0; i < dtSettlement.Rows.Count; i++)
                {
                    sum+= Convert.ToDecimal(dtSettlement.Rows[i].ItemArray[dtSettlement.Columns.IndexOf("Money")]);
                }

                // 合计
                if (e.Row.RowType == DataControlRowType.Footer)
                {
                    e.Row.Cells[0].Text = "合计";
                    e.Row.Cells[4].Text = sum.ToString();
                }
            }
        }
		
		
		
		OnRowDataBound="gridSettlement_RowDataBound"

  

这篇关于C#gridview尾部统计的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!