Try this
just calculate the count
it works

protected void GridView1_RowDa taBound(object sender, GridViewRowEven tArgs e)
{
if(e.Row.Cells. Count>2)
{
e.Row.Cells[2].Visible = false;
}
}