add summary rows to datagrid

G

Guest

hi,

i need to subtotal a column in a datagrid and display the result. I have
come to a point where i can subtotal the columns in the datagrid but cannot
display the result.

ex.
Private Sub dgTimesheet_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgTimesheet.ItemDataBound
If e.Item.Cells(4).Text().GetType Is GetType(System.Double) Then
subtotal += Double.Parse(e.Item.Cells(4).Text())
End If
End Sub

my question is how do i know when the datagrid has finished binding and then
add a literal at the bottom of the grid and display the subtotal.

thanks in advance.
 
G

Guest

well it works now. i made a silly mistake in my if statement.

my bad.

corrected code:
Private Sub dgTimesheet_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgTimesheet.ItemDataBound
If IsNumeric(e.Item.Cells(4).Text()) Then
subtotal += Double.Parse(e.Item.Cells(4).Text())
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top