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

Pagination in my UI

Dheeraj Joshi
1,123 Expert 1GB
Hi all,

I have a list view in which i populate data from data base. Now i want only 10 data displayed in my list view and next 10 when i click on next page icon and so on.

I thought of a solution and it goes like this:

If there are 100 data in database count the number of data and divide it in to group of 10. So now we have 10 groups(Considering 100 data). Insert each 10 data into a hash table. So we get 10 Hash table. Now create array list of hash table.

Now count number of items in array list and display the numbers(It represent the page number). so clicking on that number(say 5 for example) hash table in array list position 5 will get displayed.

Is there any smarter way to approach this problem than what i thought. Inputs are appreciated.

Regards
Dheeraj Joshi
Oct 26 '09 #1
3 2546
tlhintoq
3,525 Expert 2GB
Not sure why you need to added layer of a hash table.
The math for what to display is straightforward:
10 items per page * your page number + item on that page

Expand|Select|Wrap|Line Numbers
  1. for (int Index = 0; Index < PerPage; Index++)
  2. {
  3.    DIsplay(MyData[(CurrentPage*PerPage) + Index];
  4. }
Oct 26 '09 #2
Dheeraj Joshi
1,123 Expert 1GB
@tlhintoq
Oh... Yeah... Sounds like a good answer. I will implement it in same way.

Now Got a design question.

Now if i want to make pagination as separate component.(So many list views can use same pagination idea). How to strip pagination logic from List view. So pagination will be separate thing.So from list view what need to be passes to pagination component, and what to return. I am not getting any idea to make pagination as a widget.

Regards
Dheeraj Joshi
Oct 26 '09 #3
tlhintoq
3,525 Expert 2GB
I like where you thinking is going with that. I like making re-usable code in the form of components, as often as I can.

I don't do much with grid views, grid controls etc., so I don't see an idea for a control that will handle 1 column or 10, 20 rows or 2000 - that doesn't look so generic it would be boring - and I hate boring.

You could create a seperate navigation pallet that could be reused though. Some thing with "first, last, next previous, search bar, etc." Maybe if that took your entire table of data it could become self contain???
Oct 26 '09 #4

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

Similar topics

9
by: Sharif T. Karim | last post by:
Anyone know of a up-to-date tutorial for pagination where I can have it like: Prev 1 2 3 4 Next Thanks. -- Sharif T. Karim ....you don't know wrath yet...
1
by: Faree | last post by:
I am workign on a news portal which needs paginaiton as usual.but all the code i got depends on the number of records that will come from database :( .it is working well too. But i need...
1
by: Kruq | last post by:
Is it possible to use pagination with DataList? Can't find it.. :( Kruq
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...
11
by: ste | last post by:
Hi there, Further to my recent posts where I've received excellent help from Rik and Jerry, I've ended up with an image gallery on my website that displays images in a table, 3 images per row. ...
1
by: dhanu | last post by:
How to manage pagination in AJAX? My requirement is similar to GMails inbox feature. Whenever a new mail comes in,the newly arrived mail is at the start of my inbox and last row in that page...
1
by: shalini jain | last post by:
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code. Below is the code that...
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) ...
4
by: ArizonaJohn | last post by:
Hello, The code below works great. The user enters a name into an HTML form, the code looks up a table with that name, and then that table is displayed. I am trying to use pagination with it,...
2
by: kkshansid | last post by:
this is my search page on which i am getting two parameters from previous page but the problem is that as soon as i click any other next pages my sql query fails as it doesnt get these two parameters...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.