Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
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 20:37pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Er Anuj Kaushal at 18-Nov-12 10:29am
I am really glad to receive your reply but Sir/Mam i need solution for window apps. in . 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.
__TR__ at 19-Nov-12 0:19am
Check this article
Summary DataGridView[^]
Hope this helps.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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);
                  case "BLANKET":
                      blanketSum += Convert.ToInt32(dataGridView1.Rows[i].Cells["ITEM QUANTITY"].Value);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 405
1 Sergey Alexandrovich Kryukov 272
2 OriginalGriff 165
3 George Jonsson 159
4 Richard MacCutchan 110
0 OriginalGriff 6,344
1 Sergey Alexandrovich Kryukov 5,890
2 CPallini 5,175
3 George Jonsson 3,559
4 Gihan Liyanage 2,522

Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100