I'm displaying records from a database and need only to display 20 records on a page - if records are more than 20 a link 'next20' and 'pre20' should display but it less the link shouldn't display.
Here's my code tell me what I'm doing wrong:
<%Const iPageSize = 20
dim LogInID, intPageCnt, intTotalPage, intAbsolutePage, intCurrentPage
intCurrentPage = CInt(Request("CurrentPage")
Select Case Trim(Request("pg")
Case "prev" :
intCurrentPage = intCurrentPage - 1
Case "next" :
intCurrentPage = intCurrentPage + 1
End Select
if intCurrentPage = 0 then intCurrentPage = 1
if Not (rs.EOF) then
rs.AbsolutePage = intCurrentPage
intTotalPage = rs.PageCount
end if
%>
<table width="100%" border="0" cellpadding="1" cellspacing="1">
<tr>
<td colspan="1" align="center">
<input type="hidden" name="CurrentPage" value="<%=intCurrentPage%>">
<%if intCurrentPage > 1 then%>
<a href="Admin.asp?pg=prev&CurrentPage=<%=intCurrentPage%>">Previous 20 </a>
<%end if%>
<%if intCurrentPage <> intTotalPage -1 then %>
<a href="Admin.asp?pg=next&CurrentPage=<%=intCurrentPage%>">Next 20 </a>
<%end if%>
</td>
</tr>
</table>
Here's my code tell me what I'm doing wrong:
<%Const iPageSize = 20
dim LogInID, intPageCnt, intTotalPage, intAbsolutePage, intCurrentPage
intCurrentPage = CInt(Request("CurrentPage")
Select Case Trim(Request("pg")
Case "prev" :
intCurrentPage = intCurrentPage - 1
Case "next" :
intCurrentPage = intCurrentPage + 1
End Select
if intCurrentPage = 0 then intCurrentPage = 1
if Not (rs.EOF) then
rs.AbsolutePage = intCurrentPage
intTotalPage = rs.PageCount
end if
%>
<table width="100%" border="0" cellpadding="1" cellspacing="1">
<tr>
<td colspan="1" align="center">
<input type="hidden" name="CurrentPage" value="<%=intCurrentPage%>">
<%if intCurrentPage > 1 then%>
<a href="Admin.asp?pg=prev&CurrentPage=<%=intCurrentPage%>">Previous 20 </a>
<%end if%>
<%if intCurrentPage <> intTotalPage -1 then %>
<a href="Admin.asp?pg=next&CurrentPage=<%=intCurrentPage%>">Next 20 </a>
<%end if%>
</td>
</tr>
</table>