add total row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm populating my datagrid via sql of course and i have some SUM(table) as
total in it as well. Now on my grid I want to show the Totall in the footer
of the grid, How can i show the Total in the "footer" such as


The Total cars sold is: 45,252
 
Sub KeepRunningSum(sender As Object, e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item OR _
e.Item.ItemType = ListItemType.AlternatingItem then
runningSum += Convert.ToSingle(DataBinder.Eval(e.Item.DataItem,
"Cars Sold"))
ElseIf e.Item.ItemType = ListItemType.Footer then
e.Item.Cells(3).Text = "<b>Total cars sold isl:</b> " &
String.Format("{0:c}", runningSum)
End If
End Sub

<asp:Datagrid id="Cars" OnItemDataBound="KeepRunningSum"></asp:datagrid>
 

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

Back
Top