HighTechTalks DotNet Forums  

GridView Total

Visual Studio.net (General) microsoft.public.vsnet.general


Discuss GridView Total in the Visual Studio.net (General) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Peter Newman
 
Posts: n/a

Default 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

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.