I want to sum cells in DataGridView and display the result in a MessageBox.

I have two DataGridViews. The first DataGridView gets data from database. The second DataGridView gets values after I select row from first DataGridView.

This is my code

```
   private void actionStatistics_Click(object sender, EventArgs e)
    {
        int total = 0;

        for (int i = 0; i < productsDataGridView.Rows.Count; i++)
        {
            total += int.Parse(productsDataGridView.Rows[i].Cells[6].Value.ToString());
        }

        MessageBox.Show("Total quantity: " + total);
    }  

```

I get error in this line:

```
     total += int.Parse(productsDataGridView.Rows[i].Cells[6].Value.ToString());

```

Error is:

```
     An unhandled exception of type 'System.NullReferenceException' occurred in task3.exe. 
     Additional information: Object reference not set to an instance of an object.

```

Can someone help me find a solution?