System.NullReferenceException
This simply means that you are trying to use a property of an object which is actually a NULL.
Now, looking at the line you say:
DataGridView1.Rows[iIndex].Cells[1].Value = iGLCount.ToString();
Potential objects, which can be easily debugged, seen and rectified are:
Check sequentially:
1.
iGLCount
: Is this object NULL? If so, doing a ToString() would throw an error
2.
DataGridView1.Rows[iIndex]
: Does this return a valid row object? If yes, move ahead for third and last one
3.
DataGridView1.Rows[iIndex].Cells[1]
: Does this return a proper object? If not, and is a NULL, then doing a .Value would throw an error.
Now, just check which one of it is (1 or 2 or 3) and handle the same. Have a NULL check before using it.