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.

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...

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.