现在的位置: 首页 > 综合 > 正文

gridview求和

2013年05月07日 ⁄ 综合 ⁄ 共 326字 ⁄ 字号 评论关闭
 前台:设置gridview的ShowFooter="True" ,否则默认表头为隐藏的! 
后台代码
RowDataBound事件  
 private double sum = 0;
    protected void GetAccountsOpened10_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex >= 0)
        {
            sum += Convert.ToDouble(e.Row.Cells[1].Text);
        }
        else if (e.Row.RowType == DataControlRowType .Footer)
        {
            e.Row.Cells[1].Text = "total:" +sum.ToString();
       
        }
    }

 

抱歉!评论已关闭.