views:

938

answers:

3

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

+5  A: 

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;
}
David M
thanks for the fast response ;)another greater 'feature' design...
AWC
A: 

When the number of pages is one, there is no need to show Next/Previous or other pages. Sounds like normal behavior to me.

Rap
it's no good if I want to dynamically change the number of rows displayed by a drop down in the pager...But there again I shouldn't really allow the user to change the number of rows displayed in the pager that's just a stupid requirement...
AWC
A: 

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; }

John Rossitter