GridView Total -
06-12-2009
, 03:58 AM
I am populating a gridview using SQLDataSource. The SQLDataSource fires a
stored procedure. This all works fine and the grid gets populated.
The gridview has paging enabled. My problem is that in the footer I want to
get a Grandtotal of "Costs" for all the gridview pages and put it in the
footer. So far I have only been able to manage getting a total for "Costs"
for the page that is currently on display
code used is
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowType = DataControlRowType.Header Then
Do Something ....
ElseIf e.Row.RowType = DataControlRowType.DataRow Then
TTransfer +=
Convert.ToDecimal(e.Row.Cells(COSTS).Text).ToStrin g("#,##0.00")
ElseIf e.Row.RowType = DataControlRowType.Footer Then
e.Row.Cells(9).Text = "Totals"
e.Row.Cells(COSTS).Text =
Convert.ToDecimal(TTransfer).ToString("#,##0.00")
e.Row.Cells(COSTS).HorizontalAlign = HorizontalAlign.Right
End If
End Sub
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
TTransfer +=
Convert.ToDecimal(e.Row.Cells(12).Text).ToString(" #,##0.00")
End If
End Sub
any idea's |