Forum Moderators: open

Message Too Old, No Replies

Pages are being NOT being displayed

Tables are displayed in a page manner

         

vanjamier

1:28 am on Jan 20, 2005 (gmt 0)

10+ Year Member



Hi i did a function to display tables in pages.
The next and previous link works fine
However, the page number is not being display..how come?

<html>
<%
Sub BuildNav (intPrev,intNext,TotalPages)

Dim counter
Response.Write "<font face=verdana size=1><b>"

'If the previous page id is not 0, then let's add the 'prev' link.

If intPrev <> 0 then

With Response

.Write "<a href=admin_view.asp?PageIndex="
.Write intPrev & "><< previous</a>"
.Write NBSP(5)
End With
End If

'This displays the list of page numbers as links, separated with the pipe ( ¦ )

counter = 1
Response.Write "Jump to Page: "
do while counter <= TotalPages

'If the current page is the same as the counter, then write the page number with no hyperlink

If cint(counter) = cint(PageIndex) then

Response.Write counter
Else
'Else write the page number as a hyperlink to that page

Response.Write "<a href=admin_view.asp?PageIndex="
Response.Write counter & ">" & Counter & "</a>"
End if

'As long as not at the last page number in this loop add a pipe to the string.

If cInt(counter) <> TotalPages then
Response.Write " ¦ "
End If

counter = counter + 1
Loop

If (rs.AbsolutePage <> -3) then
With Response
.Write NBSP(5)
.Write "<a href=admin_view.asp?PageIndex="
.Write intNext & ">next >></a>"
End With
End If
End Sub
%>
<%
function NBSP(count)
dim i
for i = 1 to count
NBSP = NBSP + "&nbsp;"
next
end function
%>

<%
on error goto 0

Dim IntPageSize, PageIndex, TotalPages, TotalRecords
Dim RecordCount, RecordNumber

IntPageSize = 50
PageIndex = Request("PageIndex")

'If pageIndex is empty, set it to one.
if PageIndex = "" then PageIndex = 1

'open the database from database.inc file
OpenDatabase()

'RecordSet Object
Set rs = CreateObject("ADODB.RecordSet")
strsql = "select * from sunder.mobile_users"
rs.Open strsql, conn, 3

RecordCount = rs.RecordCount
RecordNumber = (PageIndex * IntPageSize) - (IntPageSize)

rs.PageSize = intPageSize ' Set the number of records per page
rs.AbsolutePage = PageIndex 'Define what page number on which

'the current record resides

dim intPrev, intNext
intPrev = PageIndex - 1
intNext = PageIndex + 1 'same as rs.AbsolutePage

Dim Count

'Building table headers
Dim disname(3) disname(0) = "Name" disname(1) = "Phone_No" disname(2) = "Department"
%>

<!-- Display Table -->
<table border="" cellspacing="1" cellpadding="2" borderColor=cornflowerblue borderColorDark=darkorange bgColor=white id=TABLE1>
<tr>
<% for i = Lbound(disname) to UBound(disname) -1 %>
<%Response.Write "<th>" & disname(i) & "</th>"
next%>
</tr>
<%
If Not rs.EOF Then
Do While Not rs.EOF And Count < IntPageSize
%>
<tr>
<td><%=rs("NAME")%></td><td><%=rs("PHONE_NO")%></td><td><%=rs("DEPT")%></td>
</tr>
<%
rs.MoveNext
Count = Count + 1
Loop
%>
<%End If%>
</table>
<%
call BuildNav (intPrev,intNext,TotalPages)
'Close connection
rs.Close
Set rs = Nothing
%>
</body>
</html>

Im relatively new to asp...
I hope someone can drop me the solution, thanks in advance.

vanjamier

5:17 am on Jan 20, 2005 (gmt 0)

10+ Year Member



I got it working
i realised total pages wasnt declared...

so i just changed it to
"do while counter <= rs.PageCount"