作者j88lb (尿布)
看板Visual_Basic
標題[ASP ] Gridview 分頁 總計問題
時間Tue Jan 17 17:17:29 2012
不好意思又來請教各位~
目前在做gridview連結access資料庫時遇到的問題
程式碼如下:
Dim priceTotal3 As Decimal = 0
Dim quantityTotal3 As Decimal = 0
Protected Sub GridView13_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView13.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
priceTotal3 += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, _
"cost"))
quantityTotal3 += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, _
"num"))
ElseIf e.Row.RowType = DataControlRowType.Footer Then
e.Row.Cells(0).Text = "小計:"
e.Row.Cells(3).Text = quantityTotal3.ToString("d")
e.Row.Cells(4).Text = priceTotal3.ToString("c")
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right
e.Row.Font.Bold = True
End If
End Sub
這樣的寫法只能呈現出每個分頁的加總在footer上
請問要如何將分頁的小計作加總呢??
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.120.98.114
推 brian90191:其實我建議你直接針對你的資料來源做處理 01/17 23:33
→ j88lb:我是用access的資料庫 請問可以抓取裡面的總和資料嘛? 01/18 14:59
推 TeemingVoid:select sum(欄位名稱) from 資料表名稱 where ... 01/18 21:24