Click here to Skip to main content
15,666,844 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Now i work on Account software so in the last of the datagridview in C# 2008 I want to sum of both debit and credit field and opening balance also in different row so what is the best way regarding this please help

Thank You Advance
Satnam singh
Muktsar
Posted
Comments
Herman<T>.Instance 22-Mar-12 7:44am    
what is your problem? please elaborate your question.

1 solution

You can do it in 2 ways:
1) loop thrue all rows in DataGridView
In pseudocode:
C#
For i = 0 to DGV.Rows.Count-1
    sum+=DGV.Rows[i].Item["Debit"].Value
Next

2) get sum from query
SQL
SELECT SUM(Debit) AS [SumOfDebit]
FROM TableName
WHERE condition


I don't know:
a) where you want to show it (in the last row of DGV or in the textboxes?),
b) the source of data (SQL Server, Access, etc.?)

If you provide more information, i'll improve my answer.
 
Share this answer
 

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