GridView统计单列或多列的总数

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        CellPadding="4" ForeColor="#333333" GridLines="None" ShowFooter="True" 
        onrowdatabound="GridView1_RowDataBound">

//数据统计至页脚显示
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[9].Text = "实付总额:";
            // dt即数据源DataTable
            e.Row.Cells[10].Text = dt.Compute("sum(买家实际支付金额)", "").ToString();
        }
    }

原文地址:https://www.cnblogs.com/smartsmile/p/6234356.html