用Dreamweaver和ASP實現分頁技術的參考(2)_Dreamweaver教程
若要顯示所有連接的頁(個)數,你可以設置為:NaviLength=tPageCount。
這時代碼已經差不多了,但還要在顯示的地方(如表格)中加點代碼才行吧,(要不然怎么顯示,呵~~~)如我們插入一個2行3列的表格。
1.將光標移在第一行第一列中,切換到代碼中加入:<%=(PageNo-1)*RPP I%>
這個代碼是顯示序號用的。
2.右邊2個單元格(當然你自己可以根據需要分更多的列)就是為你要顯示的記錄了。請分別從綁定的記錄集中選中你要顯示的字段拖放在相應的單元格中,(也可以選中后再點右下角的“插入”按鈕)。這里我們就先拖2個進來如“編號”和“公司名稱”。分別到1行第2個單元格和1行第3個單元格中。
3.這個是個要害的,請將光標移到第一行任意單元格中,再來點選窗口底下的<tr>,這時你看看代碼,<tr>....</tr>就被選中了。這時請在<tr>....</tr>的前面插入如下代碼:
<%
If Recordset1.EOF OR Recordset1.BOF Then
Else
For I=1 To RPP
%>再在<tr>....</tr>之后插入如下代碼:
<%
Recordset1.MoveNext
If Recordset1.EOF OR Recordset1.BOF Then Exit For
Next
End If
%>
<% showPageInfo Recordset1.PageCount,PageNo %>
的代碼。右邊的2個單元格將其合并,在代碼中插入:<% showPageNavi Recordset1.PageCount,PageNo %>
的代碼。
5.大功告成!這時感快預覽一下吧。。。。
表格的全部代碼如下:
<table width="710" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#333333">
<%
If Recordset1.EOF OR Recordset1.BOF Then
Else
For I=1 To RPP
%>
<tr bgcolor="#FFFFFF">
<td width="30" align="center"><%=(PageNo-1)*RPP I%></td>
<td><%=(Recordset1.Fields.Item("編號").Value)%></td>
<td><%=(Recordset1.Fields.Item("公司名稱").Value)%></td>
</tr>
<%
Recordset1.MoveNext
If Recordset1.EOF OR Recordset1.BOF Then Exit For
Next
End If
%>
<tr bgcolor="#FFFFFF">
<td colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr bgcolor="#006699" class="w12">
<td width="121" align="center"><% showPageInfo Recordset1.PageCount,PageNo %>
</td>
<td width="573" align="center">
<% showPageNavi Recordset1.PageCount,PageNo %>
</td>
</tr>
</table></td>
</tr>
</table>
<%
Dim I
Dim RPP’RPP:指定每頁顯示的記錄條數,
Dim PageNo
I=1
RPP=50
PageNo=CInt(Request("PageNo"))
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_數據庫名_STRING
- 相關鏈接:
- 教程說明:
Dreamweaver教程-用Dreamweaver和ASP實現分頁技術的參考(2)。