paging logic

  • Thread starter Thread starter André Freitas
  • Start date Start date
A

André Freitas

Im building a manualy paging. And I got a problem that im trying to solve
for a long time.

I do have:
int pageCount;
int pageIndex;

And:
<asp:LinkButton ID="lnk1" runat="server" OnClick="LinkButton_OnClick" />
<asp:LinkButton ID="lnk2" runat="server" OnClick="LinkButton_OnClick" />
<asp:LinkButton ID="lnk3" runat="server" OnClick="LinkButton_OnClick" />
<asp:LinkButton ID="lnk4" runat="server" OnClick="LinkButton_OnClick" />
<asp:LinkButton ID="lnk5" runat="server" OnClick="LinkButton_OnClick" />

I do need a logic to do something like that:

Suposing
int pageCount = 6;
int pageIndex = 1 (default);

First load ([] means disabled):
[1] 2 3 4 5

User clicks 2:
1 [2] 3 4 5

User clicks 3:
1 2 [3] 4 5

User clicks 4:
2 3 [4] 5 6

User clicks 6 (last page):
2 3 4 5 [6]

User clicks 5:
2 3 4 [5] 6

Suposing
int pageCount = 3;
int pageIndex = 1 (default);

First load ([] means disabled):
[1] 2 3

User clicks 2:
1 [2] 3

User clicks 3:
1 2 [3]


I ll be glad if someone can help me. Regards.
 
Im building a manualy paging. And I got a problem that im trying to solve
for a long time.

I do have:
    int pageCount;
    int pageIndex;

And:
<asp:LinkButton ID="lnk1" runat="server" OnClick="LinkButton_OnClick" />
<asp:LinkButton ID="lnk2" runat="server" OnClick="LinkButton_OnClick" />
<asp:LinkButton ID="lnk3" runat="server" OnClick="LinkButton_OnClick" />
<asp:LinkButton ID="lnk4" runat="server" OnClick="LinkButton_OnClick" />
<asp:LinkButton ID="lnk5" runat="server" OnClick="LinkButton_OnClick" />

I do need a logic to do something like that:

Suposing
    int pageCount = 6;
    int pageIndex = 1 (default);

First load ([] means disabled):
[1] 2 3 4 5

User clicks 2:
1 [2] 3 4 5

User clicks 3:
1 2 [3] 4 5

User clicks 4:
2 3 [4] 5 6

User clicks 6 (last page):
2 3 4 5 [6]

User clicks 5:
2 3 4 [5] 6

Suposing
    int pageCount = 3;
    int pageIndex = 1 (default);

First load ([] means disabled):
[1] 2 3

User clicks 2:
1 [2] 3

User clicks 3:
1 2 [3]

I ll be glad if someone can help me. Regards.

You can use special css style to highlight the link to the current
page. You can also use a literal instead of label control. In literal
you can programmatically define if you want a link or just a [X]
 
Back
Top