list.asp
来自「用ASP写的电子购物系统」· ASP 代码 · 共 168 行
ASP
168 行
<% REM ######################################################################### %>
<% REM %>
<% REM LIST.ASP %>
<% REM Microsoft Commerce Server v3.00 %>
<% REM %>
<% REM Copyright (c) 1996-98 Microsoft Corporation. All rights reserved. %>
<% REM %>
<% REM ######################################################################### %>
<%
REM -- set flag defaults
EmptyRecordset = False
FirstPass = True
NeedRecordset = False
REM -- initialize page variables
RecordsProcessed = 0
PageSize = stdListRange
REM -- get control for going from page to page (from form)
PagingMove = Request("list_PagingMove")
REM Get the page we are on
ListAbsolutePage = Request("ListAbsolutePage")
if IsNull(ListAbsolutePage) then
ListAbsolutePage = 1
end if
REM -- load recordset
Set rsList = Server.CreateObject("ADODB.Recordset")
rsList.CacheSize = stdListRange
rsList.Open cmdTemp,, adOpenStatic, adLockReadOnly
REM check for empty record set (beginning and end the same or can't get EOF or BOF)
On Error Resume Next
If rsList.BOF And rsList.EOF Then EmptyRecordset = True
On Error Goto 0
If Err Then EmptyRecordset = True
rsList.PageSize = PageSize
REM -- act on pagemove instruction (from form)
If Not EmptyRecordset Then
If Not rsList.Supports(adApproxPosition) then 'not SQL Server - probably Oracle
While Not rsList.EOF
RecordCount = RecordCount + 1
rsList.MoveNext
Wend
rsList.MoveFirst
PageCount = Round(RecordCount/PageSize)
If PageCount < RecordCount/PageSize then PageCount = PageCount + 1
else
PageCount = rsList.PageCount
RecordCount = rsList.RecordCount
end if
Select Case PagingMove
Case "首页"
ListAbsolutePage = 1
Case "上一页"
ListAbsolutePage = ListAbsolutePage - 1
Case "下一页"
ListAbsolutePage = ListAbsolutePage + 1
Case "尾页"
ListAbsolutePage = PageCount
Case Else
End Select
If (ListAbsolutePage - 1) * PageSize > RecordCount or ListAbsolutePage < 1 Then ListAbsolutePage = 1
If Not rsList.Supports(adApproxPosition) then 'not SQL Server - probably Oracle
StartRecord = ((ListAbsolutePage - 1) * PageSize)
For i = 1 to StartRecord
If rsList.EOF then exit for
rsList.MoveNext
Next
else
rsList.AbsolutePage = ListAbsolutePage
end if
If rsList.EOF Then
ListAbsolutePage = ListAbsolutePage - 1
If Not rsList.Supports(adApproxPosition) then 'not SQL Server - probably Oracle
rsList.MoveFirst
StartRecord = ((ListAbsolutePage - 1) * PageSize)
For i = 1 to StartRecord
If rsList.EOF then exit for
rsList.MoveNext
Next
else
rsList.AbsolutePage = ListAbsolutePage
end if
End If
End If
REM -- show the column headings
%>
<TABLE BORDER=1 CELLPADDING=0 cellspacing=0 bordercolorlight="black" bordercolordark="white" bordercolor="black">
<TR VALIGN="top"> <!--#INCLUDE FILE="list_column.asp" --> </TR>
<%
REM -- show no rows message if the recordset is empty
If EmptyRecordset Then
%>
<TR>
<TD COLSPAN=10>
<TABLE BORDER=0>
<TR>
<TD COLSPAN=10>
<!--#INCLUDE FILE="list_no_rows.asp" -->
</TD>
</TR>
</TABLE>
</TD>
</TR>
<%
REM -- else show the row information for each row
Else
RowCount = ((ListAbsolutePage - 1) * PageSize) + 1
Do
If EmptyRecordset Then Exit Do
If RecordsProcessed = PageSize Then Exit Do
If Not FirstPass Then
rsList.MoveNext
Else
FirstPass = False
End If
If rsList.EOF Then Exit Do
RecordsProcessed = RecordsProcessed + 1
%>
<TR class=main><!--#INCLUDE FILE="list_row.asp" --></TR>
<%
RowCount = RowCount + 1
Loop
End If
%>
</TABLE>
<%
REM -- show navigation bar (if more than 1 page)
If PageCount > 1 and Not EmptyRecordset Then
%>
<TABLE BORDER=0 CELLSPACING=3>
<TR>
<TD ALIGN=CENTER BGCOLOR=<%=tdleft4%>>
<NOBR><% = RecordCount %> 记录 第 <% = ListAbsolutePage %> 页 共 <% = PageCount %> 页</NOBR>
</TD>
</TR>
<TR>
<TD>
<FORM ACTION="<% = Request.ServerVariables("PATH_INFO") %>" METHOD=POST id=form1 name=form1>
<% If ListAbsolutePage= PageCount or ListAbsolutePage>1 Then %>
<INPUT TYPE="Submit" NAME="list_PagingMove" VALUE="首页">
<INPUT TYPE="Submit" NAME="list_PagingMove" VALUE="上一页">
<% End If %>
<% If ListAbsolutePage = 1 or ListAbsolutePage<PageCount Then %>
<INPUT TYPE="Submit" NAME="list_PagingMove" VALUE="下一页">
<INPUT TYPE="Submit" NAME="list_PagingMove" VALUE="尾页">
<% End If %>
<input type="hidden" name="move" value="yes">
<INPUT TYPE="Hidden" NAME="ListAbsolutePage" VALUE="<% = ListAbsolutePage %>">
</FORM>
</TD>
</TR>
</TABLE>
<% End If %>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?