ASP中实现分页显示的七种武器
2006-04-07 11:58:01 来源:WEB开发网第四步:编写显示每一页的函数。其中使用了许多DHTML的属性和方法,请读者自行参考相关书籍。
Sub DisplayData()
startRecord = ((gCurrentPageNumber - 1) * gRecordsPerPage) + 1 //计算每一页开始显示的记录号数(位置,第几条)
rowCtr = 1
lblPageNumber.innerHTML = gCurrentPageNumber & "/" & gMaxPageNumber
For recordPtr = startRecord To (startRecord + gRecordsPerPage - 1) //循环显示一页的各条记录
If recordPtr > Recordset1.getCount() Then //显示空表
Table1.rows(rowCtr).cells(0).innerHTML = "<P> </P>"
Table1.rows(rowCtr).cells(1).innerHTML = "<P> </P>"
Table1.rows(rowCtr).cells(2).innerHTML = "<P> </P>"
Table1.rows(rowCtr).cells(3).innerHTML = "<P> </P>"
Else //具体显示每一页
Recordset1.moveAbsolute(recordPtr) //移动记录指针。
empID = Recordset1.fields.getValue("emp ID")
empLName = Recordset1.fields.getValue("first name")
empFName = Recordset1.fields.getValue("last name")
Table1.rows(rowCtr).cells(0).innerText = recordPtr ’ Counter
Table1.rows(rowCtr).cells(1).innerText = empID
Table1.rows(rowCtr).cells(2).innerText = empLName
Table1.rows(rowCtr).cells(3).innerText = empFName
End If
rowCtr = rowCtr + 1
Next
End Sub
更多精彩
赞助商链接