Without knowing which line it is complaining about we can't be precise. But it's one of two lines:
int userid = Convert.ToInt32(GridView1.DataKeys[gridrow.RowIndex].Value.ToString());
string username = gridrow.Cells[0].Text;
Either gridRow is not a row in the GridView1 control, or there are no cells in the row. Check both, and work out which. You may want to look at when this happens, and if anything sensible is assigned to gridRow at that point.