ASP.NET简单分页链接

时间:2018-01-26 23:33:31

标签: asp.net sql-server paging

在SP中实施的分页: 从SQL SP中,我在每行100行中获得12行。 我也得到“TotalCount = COUNT(*)OVER()”。

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

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

提前致谢。

1 个答案:

答案 0 :(得分:0)

    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>