Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi...
I am developing a web application using asp.net and c#.
I am retrieving data in Dataset as:
Outcome WithinPeriod Total
Outcome1 4 10
Outcome2 8 20
Outcome3 3 19

I am retrieving all the Outcome1,Outcome2..from Outcome master.
Here all the distinct Outcomes will be displayed.
Also in withinperiod and Total Field,I am retrieving count of that outcome withing that period and Total count from Enquiry Table.
Now my problem is that i want calculate total sum under column withinperiod and Total for all outcome in dataset.
it should be:
Outcome WithinPeriod Total
Outcome1 4 10
Outcome2 8 20.
Outcome3 3 19
Total(This value should be calculated for all above outcome).
How to calculate sum of all datarow values in last row.
Posted

According to me you can not get total of it in last row but yes using for or foreach loop you will get total in temp variable and after that you can add one row in yr datatable with "total" Outcome n some in WithinPeriod and total respectively.
 
Share this answer
 
hi, you can get data by this way:
1. you can get rows data by sql and bind datatable.
2. you can total you need column filed by sql and save to dataRow, eg:
select sum(Column1),...
3. at last you add dataRow data to datatable.


hope this suggestion help u.
 
Share this answer
 
Comments
Helen.Yu 26-Jul-10 4:27am    
the best way using foreach loop data.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900