Displaying Total in Footer of GridView and also Add Sum of columns(row vise) in last Column

前端 未结 4 1658
离开以前
离开以前 2020-12-07 01:12

In my Asp.net App, i have a GridView and i generate the data of column[6] by myself using code behind.

by looking at the code below, i have

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 01:54

    protected void gvBill_RowDataBound(object sender, GridViewRowEventArgs e)
        {
    
            if (e.Row.RowType == DataControlRowType.DataRow)
    
                Total += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "InvMstAmount"));
            else if (e.Row.RowType == DataControlRowType.Footer)
    
                e.Row.Cells[7].Text = String.Format("{0:0}", "" + Total + "");
        }
    

提交回复
热议问题