SubTotal and GrandTotal in GridView
In the following lesson, you can learn how to implement a grouping and calculate subtotal for each group and GrandTotal for all groups in ASP.Net GridView.
In this article I have used Microsoft's Pubs database for sample data. You can download it free from the following link.
A subtotal is a total of the subgroup values and a grand total is a total of all calculations on a report. Here we retrieves data from the STOR table of PUBS databae 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.
For displaying GrandTotal at the footer, we insert a FooterTemplate at thebottom of the GridView.
And for displaying subtotal , the program dynamically add a new row after each group in the Gridview.
C# Source Code
VB.Net Source Code
- ASP.NET Simple GridView
- Sorting , Paging and AutoGenerateColumns
- ASP.NET GridView Editing
- ASP.NET GridView Delete
- DropDownList in GridView
- Create Gridview at runtime
- Gridview - Add, Edit and delete
- Gridview export to Excel
- Gridview export to CSV
- GridView summary on Footer
- Subtotal row in Gridview
- Create Gridview without database
- GridView from Stored Procedure
- How to create Gridview Popup Form
- How to create a Blank row in gridview
- Nested GridView in ASP.NET
- Freeze Gridview Header row, Scroll in GridView
- Auto Generate Row Number in GridView
- Image between GridView rows
- How to select a row in gridview
- Checkbox in ASP.NET GridView Control