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

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,

Thank you very much problem solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.