Forcing ASP.NET GridView's pager to show
Asked Answered
E

4

15

is there some way to force the gridview's pager to show up, even when there is only one page of data on screen?

I'm building a gridview-based control with a custom pager (w/dropdown for pagesize) and everything is working fine, except when user selects pagesize that is larger than the current row count of the grid. At that point the pager disappears. I've been googling this and i think that i should be doing something in override OnRowCreated...

Custom pager is added by overriding InitializePager. I'll be glad to provide more information if required!

greets, J.Arola

Erv answered 29/6, 2009 at 8:7 Comment(0)
E
25

Ok, that wasn't too hard :-)

Based on my initial testing the following did the trick:

GridViewRow pagerRow = (GridViewRow) this.BottomPagerRow;

if(pagerRow != null && pagerRow.Visible == false)
pagerRow.Visible = true;

I just added that to overridden OnPreRender, and lo, pager is visible, even when there is just one page page of data shown. Got to do some additional testing before I can be sure, though. Seems to simple to me.

Erv answered 29/6, 2009 at 8:58 Comment(0)
R
10

The above will work But this might be helpful also

GridView.BottomPagerRow.Visible=true
Roundhead answered 29/6, 2009 at 8:7 Comment(0)
A
6
   protected void GridView_PreRender(object sender, EventArgs e)
    {
        GridView gv = (GridView)sender;
        GridViewRow pagerRow = (GridViewRow)gv.BottomPagerRow;

        if (pagerRow != null && pagerRow.Visible == false)
            pagerRow.Visible = true;
    }
Anon answered 9/5, 2013 at 21:44 Comment(0)
I
3

GridView.BottomPagerRow.Visible=true works like a charm

Idolatrous answered 19/5, 2012 at 4:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.