我是超级大菜鸟。。。哈哈
先上图看看是不是你需要的
第一步,右击gridview,在事件中,单击RowdataBond事件。
在这之前一定要记得在gridview属性中的ShowFooter设置为“true”。
第二步,需要实现这个功能可以看看我的代码。
1PRotectedvoidGridView1_RowDataBound(objectsender, GridViewRowEventArgs e)23{4if(e.Row.RowType ==DataControlRowType.DataRow)567{8if(e.Row.RowIndex > -1)910{1112sum1 += Convert.ToDouble(e.Row.Cells[4].Text);13sum2 += Convert.ToDouble(e.Row.Cells[5].Text);14sum3 += Convert.ToDouble(e.Row.Cells[6].Text);1516}1718}19elseif(e.Row.RowType ==DataControlRowType.Footer)20{21e.Row.Cells[3].Text ="金额合计";22e.Row.Cells[4].Text =sum1.ToString();23e.Row.Cells[5].Text =sum2.ToString();24e.Row.Cells[6].Text =sum3.ToString();25}2627}
View Code