ASP.NET 简单的分页链接



在SP中实现的分页:从 SQL SP 中,我从 100 行中每页获得 12 行。我还得到"TotalCount = COUNT(*( OVER(("。

如果我有 100 行,而 SP 每页发送 12 行,如何在每页显示 12 行的页面上实现分页链接?

页面链接类似于:[上一页][1],[2],[3] [下一页]

提前谢谢。

    If ds.Tables(0).Rows.Count > 0 Then
    For i = 0 To ds.Tables(0).Rows.Count - 1
    CountRecordsTotal = ds.Tables(0).Rows(i)("CountOverAll")
    Next
    End If
    TotalPages = (CountRecordsTotal / 12)
    If TotalPages = 0 Then
        TotalPages = TotalPages + 1
    End If
    Max = PageNumber + 1
    If Max >= TotalPages Then
        Max = TotalPages
    End If
    Min = PageNumber - 1
    If Min <= 1 Then
        Min = 1
    End If
    PrevPage = PageNumber - 1
    If PrevPage <= 1 Then
        PrevPage = 1
    End If
    NextPage = PageNumber + 1
    If NextPage >= TotalPages Then
        NextPage = TotalPages
    End If

<ul class="pagination matches_bottom_page">
<li><a class="page_prv_nxt" href="matches.aspx?pn=<%=PrevPage%>"><i 
class="fa fa-chevron-left" aria-hidden="true"></i>&nbsp;Previous&nbsp;</a>
</li>
<% For index As Integer = Min To Max %>
<li>
<a class="page-link" href="matches.aspx?pn=<%=index%>"><%=index%></a>
</li>
<% Next %>
<li><a class="page_prv_nxt" href="matches.aspx?pn=
<%=NextPage%>">&nbsp;Next&nbsp;<i class="fa fa-chevron-right" aria-
hidden="true"></i></a></li>
<ul>

最新更新