Click here to Skip to main content
15,892,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Frds,

Id Item Qty
1 AAAA 200
1 BBBB 300
Total 500
2 CCCC 100
2 DDDD 200
Total 300
I want to sum the same ID qty and display in next row. I don't Know how to proceed this. Anyone guide me.Thanks in Advance

What I have tried:

Decimal sum1 = 0;
int i;
for (i = 0; i < dataGridView1.Rows.Count; i++)
{
sum1 += Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value);

}

dataGridView1[2, dataGridView1.Rows.Count - 1].Value = sum1.ToString();
Posted
Updated 14-Feb-16 19:04pm
v2

1 solution

Hi Inside for loop ,u can add one IF statement,i mean first get id in one variable,in if statement check that variable with grid view row,if condition success then allow to sum.

Regards
Aravindb
 
Share this answer
 
Comments
Mekalamani 15-Feb-16 2:48am    
Thank You for your suggestion. I got 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