It simply looks like your casting is incorrect
(TextBox)GridView2.Rows[e.RowIndex].Cells[1].Controls[0]).Text
Try to test the object first before casting:
if(typeof(TextBox).IsAssignableFrom(GridView2.Rows[e.RowIndex].Cells[1].Controls[0].GetType()))
{
}
;
Good luck!