12,765,284 members (36,982 online)
Rate this:
See more:
I want the total sum of items i have in grid view. like i have one column of "ITEM NAME" and another of "ITEM QUANTITY". Suppose i have entry like this

1. Blanket: 50
2.Beds: 20
3. quilts: 40
4. Mattresses: 32
5. Beds: 40
6. Blanket: 30
7:Blanket: 33
8: Beds: 50
and so on.. now i need the total no. of "BEDS" I have , Total No. Of "BLANKETS" I have and all summary of all products.
I Request you to give me the solution of my query. Thanks all
Posted 17-Nov-12 21:37pm

Rate this:

## Solution 1

Er Anuj Kaushal 18-Nov-12 10:29am

I am really glad to receive your reply but Sir/Mam i need solution for window apps. in C#.net . i need in datagridview of c# not gridview of asp.
Please help me out its the last thing of my project and then it will be over.
thanks
__TR__ 19-Nov-12 0:19am

Summary DataGridView[^]

Hope this helps.
Rate this:

## Solution 2

Hi

can you please try the below code. I couldn't check here.

```int bedSum = 0;
int blanketSum = 0;
for (int i = 0; i < dataGridView1.Rows.Count; ++i)
{
switch (dataGridView1.Rows[i].Cells["ITEM NAME"].ToString())
{
case "BEDS":
bedSum += Convert.ToInt32(dataGridView1.Rows[i].Cells["ITEM QUANTITY"].Value);
break;
case "BLANKET":
blanketSum += Convert.ToInt32(dataGridView1.Rows[i].Cells["ITEM QUANTITY"].Value);
}

}```

Top Experts
Last 24hrsThis month
 Graeme_Grant 283 OriginalGriff 270 Jochen Arndt 160 Karthik Bangalore 155 Richard Deeming 90
 OriginalGriff 5,057 Peter Leow 3,599 Karthik Bangalore 2,969 ppolymorphe 2,937 Graeme_Grant 2,909

Web02 | 2.8.170217.1 | Last Updated 18 Nov 2012