Datagrid pagination, both styles (Next/Prev and numbers) at same t

G

Guest

Hi All,

The ASP.NET Datagrid's pagination capability allows me to display either the
Next/Prev buttons or the Page numbers to allow the user to navigate through
the datagrid page by page as follows: 1) Prev Next, or 2) 1 2 3 ...

Is there any easy way on how to display both styles at the same time?

For example: Prev 1 2 3 Next

Thank you in advance!
 
A

A Traveler

No 'easy' way as far as just flip a check somewhere and its done, unfort,
no.
What you would have to do, is to catch the grids ItemCreated event, and then
in there, add the links as needed.
Below is a starting point which you could play around with and customize as
you want.
- HTH
==============================================
Private Sub grid_ItemCreated(sender As Object, e As DataGridItemEventArgs)
Handles grid.ItemCreated
Select Case e.Item.ItemType
Case Pager
'// in here, dynamically create and add as many pager buttons as
you want.
Dim lnk As LinkButton
lnk = New LinkButton
'// to prevent form validation on a simple paging operation
lnk.CausesValidation = False
'// this will be the e.NewPageIndex prop in
grid_PageIndexChanged handler
'// beware though, it is reduced by one in the PageIndexChanged.
'// so if CommandArgument = 1, then e.NewPageIndex will be = 0.
lnk.CommandArgument = 1
lnk.Text = "Your Link Text Goes Here"
e.Item.Cells(0).Controls.Add(lnk)
End Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top