Hi,
Not sure if you already got this but you could use this API:
public int CellGetIndex(int row, int column, bool clampToBorders = true)
So knowing the rows and columns of your grid, you could just iterate around those values and call that API to get the index of the cells on the edges.
Regards