Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
int sum = 0;

for (int i = 0; i < dataGridView1.Rows.Count; ++i)

{
               
 sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[38].Value);
            
}
            
txt_balance.Text = sum.ToString();
            
txt_total.Text = sum.ToString();
            
txt_Exempt.Text = sum.ToString();


am having a error like Input string is not in correct format. i want calcuate the column values if datagridview row is incremented. i tried when i execute this am getting error

pls guide...
Posted
Updated 13-Feb-13 18:14pm
v2

somewhere during your loop dataGridView1.Rows[i].Cells[38].Value has invalid integer value (as string). I suggest you debug your application to find the probelm.
 
Share this answer
 
the sum value contains special character... that why it show's the error
 
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