Reputation: 36217
I am currently working on a grid view. I am using the allow paging method which is working fine and positioned to the right of the grid view.
I want to hide the first column which is working fine except it also removing the paging numbers which stops the user from being able to change page numbers.
Below is the code I am using to hide the column
protected void tblLog_RowCreated(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Visible = false;
}
The above code hides the correct column but also hides the automatic page numbers created by the grid view allowpaging method.
Thanks for any help you can provide.
Upvotes: 1
Views: 1403
Reputation: 989
You need to add a condition for datarow and dataheader both
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Visible = false;
}
Upvotes: 1
Reputation: 15253
Check first to see if it's actually a data row:
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Visible = false;
}
Upvotes: 1