0

Hi,
I have two grid views dg1 and dg2

dg1

---------------
Qty
-------------
1
2
3

dg2
--------
Price
--------
1
2
3
I want to display the sum of qty*price in textbox ie, textbox should display the result
14(1*1+2*2+3*3).

Please it's urgent.

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by salmap
0

So what have you come up with so far? We aren't allowed to just hand you code, we need to see some sort of effort...

0

Try this code:

int total = 0;
            foreach (DataGridViewRow row1 in dgv1.Rows)
            {
                foreach (DataGridViewRow row2 in dgv2.Rows)
                {
                    if (row1.Index == row2.Index)
                    {
                        total += (int)row1.Cells[0].Value * (int)row2.Cells[0].Value;
                        break;
                    }
                }
            }
            //when code leaves these two loops (so comes here), the "total" local variable holds the result

Mitja

0

Cannot convert type 'Infragistics.Win.UltraWinGrid.UltraGridRow' to 'System.Windows.Forms.DataGridViewRow'

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.