Before setting visibility, check if it is DataRow:
EDIT : With some modification you can fix the issues you mentioned in edited question.
protected void gvVisa_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
{
// I would rather set display:hidden for ID
e.Row.Cells[0].Style.Add("display", "none");
//e.Row.Cells[0].Visible = false;
}
}
( if (e.Row.RowType == DataControlRowType.DataRowDataControlRowType.Pager)
is changed to if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
)
Here's the test project I have used. And the output from my test looks like this: