I\'m trying to run this code, and I get an exception:
Index was out of range. Must be non-negative and less than the size of the collection. Param
There are 0 cells in the newly created row, that's why you are getting that exception. You cannot use statements like
row.Cells[0].Value = i.ToString();
unless you manually add cells to the blank row.