0
点赞
收藏
分享

微信扫一扫

GridView Footer 加合计


GridView  的 ShowFooter="True"

 

页面类中定义:float sum1, sum2;

 

   protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            // 合计

            if (e.Row.RowIndex >= 0)
            {
                sum1 += float.Parse(e.Row.Cells[1].Text);
                sum2 += float.Parse(e.Row.Cells[2].Text);
              

            }
            else if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[0].Text = "合计";
                e.Row.Cells[1].Text = sum1.ToString();
                e.Row.Cells[2].Text = sum2.ToString();
            }
        }

举报

相关推荐

0 条评论