我是超級大菜鳥。。。哈哈
先上圖看看是不是你需要的
第一步,右擊gridview,在事件中,單擊RowdataBond事件。
在這之前一定要記得在gridview屬性中的ShowFooter設置為“true”。
第二步,需要實現這個功能可以看看我的代碼。
1 PRotected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 2 3 { 4 if (e.Row.RowType == DataControlRowType.DataRow) 5 6 7 { 8 if (e.Row.RowIndex > -1) 9 10 {11 12 sum1 += Convert.ToDouble(e.Row.Cells[4].Text);13 sum2 += Convert.ToDouble(e.Row.Cells[5].Text);14 sum3 += Convert.ToDouble(e.Row.Cells[6].Text);15 16 }17 18 }19 else if (e.Row.RowType == DataControlRowType.Footer)20 {21 e.Row.Cells[3].Text = "金額合計";22 e.Row.Cells[4].Text = sum1.ToString();23 e.Row.Cells[5].Text = sum2.ToString();24 e.Row.Cells[6].Text = sum3.ToString();25 }26 27 }
新聞熱點
疑難解答