pager in webpage

45 Views Asked by At

i want to create a page where there are PREV and NEXT button. when i press the NEXT button the next information where in the database sample:

ID   Firstname   Lastname   Gender  Position
112  Victor      bbb        Male    Programmer
232  Anna        xxxx       Female  Manager
301  yyyy        yyyy       male    Clerk

this data connected to other table

Sample output htm view

ID      : 112
Fullname: victor bbb      Gender : Male
Position: Programmer      Department: xxx
other information: blahblah
-------------------------------------------
<-PREV-                          -NEXT-->

when i click the next button the informtion of anna will appear. how can achieve that in asp? im new in asp so i dont now how to do that.

1

There are 1 best solutions below

0
Ali Sheikhpour On
//retrieve requested page
page = request.querystring("page")
MyPageSize=10

Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adUseClient = 3
Const adCmdText = 1 

//Make sure the requested page is valid
If page = "" Then
    page = 1
    else
    page = cint(page)
End If

DisplayNum = 0

rs.PageSize = MyPageSize
rs.CursorLocation = adUseClient 
SQL="select * from tableName order by id"
rs.Open SQL,objcon

ipage = rs.PageCount 

if page = 0 or page > ipage Then
    rs.AbsolutePage = ipage
    else
    rs.AbsolutePage = page
end if

Do While Not rs.EOF AND DisplayNum < MyPageSize

//Main Code to display data goes here for example resonse.write rs("id")&"<br>"

DisplayNum = DisplayNum + 1
rs.MoveNext
Loop

//Display navigation if pages are more than 1

If ipage > 1 Then

    if ipage > 1 And page > 1 Then
        response.write "<a href='?page="&page-1&"'>"&page-1&"</a>&nbsp;"
    end if

    For z = 1 to ipage
        If z = page then
            response.write page
            Else
            response.write "<a href='?page="&z&"'>"&z&"</a>&nbsp;"
        End If 
    Next 



    If ipage > 1 And page < ipage Then
        response.write "<a href='?page="&page+1&"'>"&page+1&"</a>"
    end if

end if
rs.Close