H
Henrik
Hello all.
I'm after some sort of pagination function.
One that takes some in data that I provide, and returns an array of
controls, pointing to page 2, page 3 etc.
Trying to mimic the way that Google handles the pagination when a lot of
pages are returned.
That is:
If you are at page 1 of 100 possible pages, you want to see the following:
1 2 3 4 5 6 7 8 9 10 >>
If you are at page 2 of 100 possible pages, you want to see the following:
<< 1 2 3 4 5 6 7 8 9 10 >>
If you are at page 22 of 100 possible pages, you want to see the following:
<< 18 19 20 21 22 23 24 25 26 >>
If you are at page 100 of 100 possible pages, you want to see the following:
<< 93 94 95 96 97 98 99 100
If you are at page 1 of 7 possible pages, you want to see the following
(don't display the pages that don't exist, ie 8, 9 and 10):
1 2 3 4 5 6 7 >>
If you are at page 2 of 7 possible pages, you want to see the following
(don't display the pages that don't exist, ie 8, 9 and 10):
<< 1 2 3 4 5 6 7 >>
If you are at page 7 of 7 possible pages, you want to see the following
(don't display the pages that don't exist, ie 8, 9 and 10):
<< 1 2 3 4 5 6 7
I'm after a function that looks like this:
public System.Web.UI.Control[] GetPageLinks(int TotalDisplayItems, int
CurrentPage, int DisplayItemsPerPage, int MaxNumberofLinks)
{
....
}
int TotalDisplayItems // Total number of items to display over the pages
int DisplayItemsPerPage // Number of items to show per page (for instance
10, 15, 25 eller 50)
int CurrentPage // The page currently displayed
int MaxNumberofLinks // Max number of links to get back from function
With that I can then loop the Control Array, and perfom the code that adds
the links at the bottom of the page, like this:
TableCell oCell = new TableCell();
foreach (System.Web.UI.Control oControl in oControls)
{
oCell.Controls.Add(oControl);
oCell.Controls.Add(new System.Web.UI.LiteralControl(nbsp;nbsp);
}
Is this something someone has done previously and is willing to share?
I know that the data I have is sufficient for the function,
but when I'm trying to write the function I end up getting dizzy
trying to catch all the possible combinations.
I gave up after 9 separate if clauses, with a switch clause inside each and
everyone.
// Henrik
I'm after some sort of pagination function.
One that takes some in data that I provide, and returns an array of
controls, pointing to page 2, page 3 etc.
Trying to mimic the way that Google handles the pagination when a lot of
pages are returned.
That is:
If you are at page 1 of 100 possible pages, you want to see the following:
1 2 3 4 5 6 7 8 9 10 >>
If you are at page 2 of 100 possible pages, you want to see the following:
<< 1 2 3 4 5 6 7 8 9 10 >>
If you are at page 22 of 100 possible pages, you want to see the following:
<< 18 19 20 21 22 23 24 25 26 >>
If you are at page 100 of 100 possible pages, you want to see the following:
<< 93 94 95 96 97 98 99 100
If you are at page 1 of 7 possible pages, you want to see the following
(don't display the pages that don't exist, ie 8, 9 and 10):
1 2 3 4 5 6 7 >>
If you are at page 2 of 7 possible pages, you want to see the following
(don't display the pages that don't exist, ie 8, 9 and 10):
<< 1 2 3 4 5 6 7 >>
If you are at page 7 of 7 possible pages, you want to see the following
(don't display the pages that don't exist, ie 8, 9 and 10):
<< 1 2 3 4 5 6 7
I'm after a function that looks like this:
public System.Web.UI.Control[] GetPageLinks(int TotalDisplayItems, int
CurrentPage, int DisplayItemsPerPage, int MaxNumberofLinks)
{
....
}
int TotalDisplayItems // Total number of items to display over the pages
int DisplayItemsPerPage // Number of items to show per page (for instance
10, 15, 25 eller 50)
int CurrentPage // The page currently displayed
int MaxNumberofLinks // Max number of links to get back from function
With that I can then loop the Control Array, and perfom the code that adds
the links at the bottom of the page, like this:
TableCell oCell = new TableCell();
foreach (System.Web.UI.Control oControl in oControls)
{
oCell.Controls.Add(oControl);
oCell.Controls.Add(new System.Web.UI.LiteralControl(nbsp;nbsp);
}
Is this something someone has done previously and is willing to share?
I know that the data I have is sufficient for the function,
but when I'm trying to write the function I end up getting dizzy
trying to catch all the possible combinations.
I gave up after 9 separate if clauses, with a switch clause inside each and
everyone.
// Henrik