In ASP.Net you can use VB.Net code to compute and display the sum of any column of GridView control. DataSet or DataTable class object enables you to store the data and schema of SQL database table in the memory of Server. These VB.Net class objects provide a Compute function that enables you to evaluate the sum of any particular column of SQL table retrieved from the database.
Further you can display the result in the Label Control placed inside the footer template of ASP.net GridView control at the bottom of associated GridView column.
VB.Net Methods Used
1. Compute
2. FindControl
The VB.Net Compute method of DataTable class object enables you to apply the agregate function "sum" over the data table column retrieved from the database. The VB.Net FindControl method can be accessed using the GridView control identifier that accepts the ID of the web server control to find and access the properties of the specified control. For example in this sample we have passed the ID of the Label control placed inside the Footer template of the GridView control to display the column sum.
Try the sample below to understand the functionality created using VB.Net code to compute the sum of the column and display it in the GridView footer: