[ASP ] Gridview 分頁 總計問題

看板Visual_Basic作者 (尿布)時間14年前 (2012/01/17 17:17), 編輯推噓2(201)
留言3則, 3人參與, 最新討論串1/1
不好意思又來請教各位~ 目前在做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

01/17 23:33, , 1F
其實我建議你直接針對你的資料來源做處理
01/17 23:33, 1F

01/18 14:59, , 2F
我是用access的資料庫 請問可以抓取裡面的總和資料嘛?
01/18 14:59, 2F

01/18 21:24, , 3F
select sum(欄位名稱) from 資料表名稱 where ...
01/18 21:24, 3F
文章代碼(AID): #1F5JoiCI (Visual_Basic)