Monday, July 30, 2007

ASP:GridView - making Pager always visible

You would have noticed this while implementing ASP.net GridView control that if the record count in the grid is lesser than the grid's page size, then the pager doesn't appear.

There can be times when you want the pager to be visible all the time (like when you implement custom paging). In such a case there is no property available in the grid which can directly let you do so. But, there is a workaround to make this happen.

To make this happen, you will have to do following -

1. Handle the GridView's PreRender event.
2. In the PreRender event, fetch the GridView's 'BottomPagerRow'
3. Set BottomPagerRow's 'Visible' property to 'True'.

Example :

Private Sub gvItems_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)Handles gvItems.PreRender

Dim gv As System.Web.UI.WebControls.GridView = CType(sender, System.Web.UI.WebControls.GridView)

    If Not gv Is Nothing Then

        Dim PagerRow As GridViewRow = gv.BottomPagerRow

        If Not PagerRow Is Nothing Then

            PagerRow.Visible = True

        End If

    End If

End Sub



Thats it!

7 comments:

Anonymous said...

die sehr wertvolle Antwort cialis preis viagra rezeptfrei [url=http//t7-isis.org]cialis online[/url]

Anonymous said...

Hello,

I am regular visitor of this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]Lots of good information here sumantdubey.blogspot.com. Do you pay attention towards your health?. Let me present you with one fact here. Research indicates that about 60% of all United States grownups are either obese or weighty[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Hence if you're one of these people, you're not alone. In fact, most of us need to lose a few pounds once in a while to get sexy and perfect six pack abs. Now next question is how you can achive quick weight loss? Quick weight loss can be achived with little effort. If you improve some of your daily diet habbits then, its like piece of cake to quickly lose weight.

About me: I am blogger of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also health expert who can help you lose weight quickly. If you do not want to go under painful training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for effortless weight loss.

Anonymous said...

hi all
http://www.tor.com/community/users/lynetgasbsi1977
http://www.tor.com/community/users/jayroblumbsoc1971
http://www.tor.com/community/users/cirlaucepmo1983
http://www.tor.com/community/users/mortkingketwi1975
http://www.tor.com/community/users/inriktiven1981

Anonymous said...

I love sumantdubey.blogspot.com! Here I always find a lot of helpful information for myself. Thanks you for your work.
Webmaster of http://loveepicentre.com and http://movieszone.eu
Best regards

Anonymous said...

top [url=http://www.c-online-casino.co.uk/]online casino[/url] hinder the latest [url=http://www.realcazinoz.com/]free casino games[/url] autonomous no store perk at the leading [url=http://www.baywatchcasino.com/]free casino games
[/url].

Anonymous said...

[url=http://loans.legitpaydayloansonline1.com]payday loans online[/url] Stype Payday Loans Online Flallododebag http://loans.legitpaydayloansonline1.com/ Fundpopog The total amount financed vs the loan name, the urgency payday is you features:.

Anonymous said...

http://www.cafb29b24.org/docs/buyativan/#54312 ativan high liver enzymes - ativan before surgery