In the following lesson, you can learn how to implement each group calculation as Subtotal and Grand Total for all groups in ASP.Net GridView.

I have used Microsoft’s Pubs database for sample data. A Subtotal is a total of the subgroup values and a Grand Total is a total of all calculations on a report. Here we retrieve data from the STOR table of the PUBS database and find the subtotal of quantities from each store and finally find the Grand Total of quantity from all stores.

For displaying quantity on each row we insert an ItemTemplate for the quantity field.

For displaying Grand Total at the footer, we insert a FooterTemplate at the bottom of the GridView.

And for displaying Subtotal, the program dynamically adds a new row after each group in the Gridview.

To calculate subtotal and grand total in GridView, you can use the following code for the design view:

To calculate subtotal and grand total in GridView, you can use the following code for the c# code:

Subtotal and Grand Total in GridView

Leave a Comment