In the following lesson, you can learn how to implement a grouping and calculate a subtotal for each group and GrandTotal for all groups in ASP.Net GridView.

SubTotal and GrandTotal in GridView | TechAid24

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 PUBS database and find the subtotal of quantities from each store and finally find the GrandTotal of quantity from all stores. For displaying quantity on each row we insert an ItemTemplate for quantity field.

subtotal and grandtotal

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

 grandtotal footer

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


C# Source Code

SubTotal and GrandTotal in GridView

Leave a Comment