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 the total of the subgroup values, and a Grand Total is the total of all calculations on a report. Here, we retrieve data from the STOR table of the PUBS database, find the subtotal of quantities from each store, and finally, find the Grand Total of quantities from all stores. To display 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 sthe ubtotal and grand total in the GridView, you can use the following code for the design view:

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

Subtotal and Grand Total in GridView

Leave a Comment