Click here to Skip to main content
15,896,474 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to read count all datagridview cell form datagridview for calculate total amount for bill form in c#.net

How we can solve this problem

What I have tried:

C#
for(int i=0;i<dgvbilling.Rows.Count;i++)
{
total=total+Convert.ToDouble(dgvbilling.Rows[i].Cells["amount"].Value.ToString());
}
Posted
Updated 24-Mar-17 23:51pm
v2
Comments
Karthik_Mahalingam 25-Mar-17 2:01am    
what is the issue ?

1 solution

Do not use the double or float types for financial applications, you will lose precision and anger your customers.

Also do not use Convert to convert strings to numbers, since you will not handle invalid data. Use <type>.TryParse.

And do not write all your code in a single line like that. You cannot see where any errors occur.

And why are you converting a value to a string just so you can convert it back to a value?
 
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