首页 > 代码库 > 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"); } }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。