Tuesday, July 14, 2009

Showing Total in GridView

'Declare Variable
Dim Total As Double


Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Select Case e.Row.RowType
Case DataControlRowType.DataRow, ListItemType.Item
'Calculate total for the field of each row and alternating row, Cell number change according to your field place
Total += CDbl(e.Row.Cells(0).Text)
Case DataControlRowType.Footer
'Use the footer to display the summary row.
e.Row.Cells(0).Text = Total.ToString("#,###.00")
End Select
End Sub

No comments:

Post a Comment