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"

  

上一篇:postgres获取普通的操作所影响的行数


下一篇:动态生成多个选择项【c#】