首页 > 代码库 > Gridview里添加合计行

Gridview里添加合计行

ShowFooter="true"

double YG_DYYGSR_BHS = 0;        double YG_DYKPSR_BHS = 0;        double YG_DYSRHJ_BHS = 0;        protected void gvIncomeYG_RowDataBound(object sender, GridViewRowEventArgs e)        {            for (int i = 0; i < gvIncomeYG.Rows.Count; i++)            {                Label lblYG_DYYGSR_BHS = ((Label)gvIncomeYG.Rows[i].Cells[18].FindControl("YG_DYYGSR_BHS"));                Label lblYG_DYKPSR_BHS = ((Label)gvIncomeYG.Rows[i].Cells[19].FindControl("YG_DYKPSR_BHS"));                Label lblYG_DYSRHJ_BHS = ((Label)gvIncomeYG.Rows[i].Cells[20].FindControl("YG_DYSRHJ_BHS"));                YG_DYYGSR_BHS += Convert.ToDouble(lblYG_DYYGSR_BHS.Text.ToString());                YG_DYKPSR_BHS += Convert.ToDouble(lblYG_DYKPSR_BHS.Text.ToString());                YG_DYSRHJ_BHS += Convert.ToDouble(lblYG_DYSRHJ_BHS.Text.ToString());            }            if (e.Row.RowType == DataControlRowType.Footer)            {                e.Row.Cells[0].Text = "合计";                e.Row.Cells[18].Text = YG_DYYGSR_BHS.ToString("0.00");                e.Row.Cells[19].Text = YG_DYKPSR_BHS.ToString("0.00");                e.Row.Cells[20].Text = YG_DYSRHJ_BHS.ToString("0.00");            }        }