473,386 Members | 1,860 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,386 software developers and data experts.

Cutomize the logic for Paging

308 256MB
Hi all,

Can anybody tell me how to cutomize the logic for Paging?

I designed the page with control dataGrid - AllowPaging is the property that perform Paging in the DataGrid.Can anybody tell me how can I implement this logic without using "AllowPaging"property ?

Thanks!
Nov 6 '09 #1
2 2449
maliksleo
115 100+
hi
just count the records and devide them on the page size you want to show. then using javascript you can perform the paging. Alot of material available on this issue on internet. Secondly you can perform paging through your code as well instead of javascript.
Define the page size and store the page number in some variable and add and subtract the values on your paging buttons click events.

maliksleo
Nov 9 '09 #2
Frinavale
9,735 Expert Mod 8TB
You don't have to use JavaScript....
It's actually pretty easy to do.

Add some controls to the page that will preform your custom paging. The controls I typically use are 2 LinkButtons (one for moving one page forward and one for moving one page back) and a DropDownList in between them which lists all of the possible pages and allows the user to automatically jump to the page that they want to.

Whenever the GridView's DataSource is changed I make sure to update the DropDownList so that it contains the number of pages that the GridView displays.

Implementing "custom paging" is really extremely simple.
In the event handler for the LinkButtons I increment or decrement the Grid's PageIndex by 1... unless the control is at the first page or the last page of course.

If the user selects a value from the DropDownList I change the PageIndex to the value that they selected.

After I change the PageIndex I check to see if the user is at the first or last page...if so I disable the paging controls that allow the user to move forward or back.

Like I said it's really really simple.

Here's an example of a method that handles the "PreviousPage" link button click event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub PreviousPage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PreviousPage.Click
  2.   If MyGridView.PageIndex > 0 Then
  3.     MyGridView.PageIndex = MyGridView.PageIndex - 1
  4.     'QuickSelectPageList is the DropDownList that lets the user jump between pages
  5.     QuickSelectPageList.ClearSelection()
  6.     QuickSelectPageList.Items(MyGridView.PageIndex).Selected = True
  7.   End If
  8. End Sub
Here is an example of code that I use to populate the DropDownList that lets the user jump between pages:
Expand|Select|Wrap|Line Numbers
  1. Private Sub InitializeGridViewQuickSelectDropDownList()
  2.   Dim numpages = MyGridView.PageCount
  3.   QuickSelectPageList.Items.Clear()
  4.   'Populating the Quick Page Select drop down list
  5.   For i As Integer = 0 To numpages - 1
  6.     QuickSelectPageList.Items.Add((i + 1).ToString)
  7.   Next
  8. End Sub
-Frinny
Nov 9 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: farhad13841384 | last post by:
Hi , I Hope You fine. I have some problem with this code for paging in asp.net this bottom code work correctly without any error but when I try to place separate code in .VB file then error is...
0
by: anonieko | last post by:
This approach I found very efficient and FAST when compared to the rowcount, or Subquery Approaches. This is before the advent of a ranking function from DB such as ROW_NUMBER() in SQL Server...
6
by: Simon Harvey | last post by:
Hi everyone, We have a need to make a Windows Forms (2.0) client application that will be installed on our clients site. The data that the application uses needs to be centrally available to a...
4
by: comp.lang.php | last post by:
'll try to explain this as clearly as possible, sorry if it's unclear. You have in your directory /foo 42 images You have in your database metadata for 30 out of those 42 images You have to...
3
by: pbd22 | last post by:
Hi. I have writting all of my paging logic in javascript. It works pretty fine. Basically, I have created a gridview with full paging in javascript. Now, given a certain need, I am being...
2
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a...
3
by: Ronald S. Cook | last post by:
I was told that if calling lots of records from the database (let's say 100,000), that the GridView's paging feature would automatically "handle" everything. But the 100,000 records are still...
5
by: Donald Adams | last post by:
Hi, I will have both web and win clients and would like to page my data. I could not find out how the datagrid control does it's paging though I did find some sample code that says they do it...
3
by: frankiefrank | last post by:
Hi, (ASP.NET question) I'm using an ObjectDataSource on a DataGridView for a custom paging/sorting scenario. I implemented a method that gets the parameters for the paging (number of rows to...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.