473,382 Members | 1,290 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

RB
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!

Nov 18 '05 #1
2 1991
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
Nov 18 '05 #2
RB
Hey, thank you for the info;

"A Traveler" wrote:
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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: EOZyo | last post by:
Hi, i'm trying to set pagination for a search i run on my website, i'll try to explain the easiest i can: When i click the search button on search.php, data is received and stored in variables...
2
by: Chris H | last post by:
I am having a problem with pagination, basically the problem is happening in the "PREV / NUMBERS / NEXT" links, it appears as if the reason is becasue the increment and decrement operators aren't...
3
by: assgar | last post by:
Hello I have a search page where you select the letter of the alphabet and the person's information who's name beginning with that letter is displayed. This function is placed on the web page...
16
by: gnawz | last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.