0

how do i add two columns in a gridview and put the total in the third column

example

exam1 exam2 total
66 20 86


how to i create the colum to genrate the total aftrer doing the query in sql

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by newcook88
0

Hi,
If you're drawing the data for the first two columns out of a database, just add a third column into the SQL query that combines the two. Then databind the gridview to the resulting table.

E.g.
Select exam1, exam2, SUM(exam1 + exam2) as total from table;

If you need to do it after the query for some reason, add a new column to the resulting dataTable from the query and then loop through inserting the sum of the two columns together. Then databind the gridview once that is done.

Check this article out for an example of the code:
http://www.codersource.net/dataset_preparing_manual_data_addition.html

Hope that helps,

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.