I have a datagridview that is using paging, it works perfectly fine and I have a drop down that allows the user to change the 'PageSize' property - 10, 15, 25, 50, 100, 1000 etc.
When I select a value for the PageSize that is greater than the row count for the grid the Pager is disappearing from both the top & bottom of the grid.
Anyone got any ideas why?
I'm using a custom PageTemplate element in the aspx page.
Cheers
Ollie
Behaviour is by design. You can force it to remain visible by setting the Visible property of the pager row (accessed using either TopPagerRow or BottomPagerRow property) in the grid's OnDataBound event. For example:
protected void grid_DataBound(object sender, EventArgs e)
{
grid.TopPagerRow.Visible = true;
}
I found that this happens if you are trying to force a column to be invisible. for example if you use:
e.Row.Cells[0].Visible = false;
You can cause the pager to render invisible.
You should use this code instead:
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header) { e.Row.Cells[0].Visible = false; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With