< !DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.01 Transitional//EN " " http://www.w3.org/TR/html4/loose.dtd " > < html > < head > < meta http - equiv = " Content-Type " content = " text/html; charset=gb2312 " > < title > asp分页显示 </ title > </ head > < body > < % dim i,intPage,page,pre,last,filepath set Conn = Server.CreateObject( " ADODB.Connection " )Conn.Open " Provider=SQLOLEDB.1;Data Source=(local);user id=sa;password=;initial catalog=ncwm " Set rs = Server.CreateObject( " ADODB.RecordSet " )Sql = " select * from wmdw " rs.PageSize = 5 ' 这里设定每页显示的记录数 rs.CursorLocation = 3 rs.Open Sql,Conn, 1 , 1 pre = true last = true page = trim (Request.QueryString( " page " )) if len (page) = 0 then intpage = 1 pre = false else if cint (page) =< 1 then intpage = 1 pre = false else if cint (page) >= rs.PageCount then intpage = rs.PageCountlast = false else intpage = cint (page) end if end if end if if not rs.eof then rs.AbsolutePage = intpage end if % > 循环体开始: < table width = " 550 " border = " 0 " cellspacing = " 0 " cellpadding = " 0 " align = " center " > < tr > < td >< table width = " 550 " border = " 0 " cellspacing = " 0 " cellpadding = " 0 " align = " center " Class = class="tblMain"> <tr> <td Class =class="tdHeadLeft" nowrap width="42%">单位名称</td> <td Class =class="tdHead" nowrap width="22%">时间</td> <td Class =class="tdHead" nowrap width="12%">浏览</td> <td Class =class="tdHead" nowrap width="8%">状态</td> <td Class =class="tdHead" nowrap width="8%">附件</td> <td Class =class="tdHead" nowrap width="8%">删除</td> </tr><% for i=1 to rs.PageSizeif rs.EOF or rs.BOF then exit for%> <tr> <td Class =class="tdBodyLeft"><%=rs("Caption")%></td> <td Class =class="tdBody"> <%=rs("IssueTime")%></td> <td Class =class="tdBody"><a href="#">浏览</a></td> <td Class =class="tdBody"><font style="{cursor:hand}"><%=rs("Status")%></font></td> <td Class =class="tdBody"><a href="#"><img src="../Images/FuJian.gif" border="0" width="15" height="15"></a></td> <td Class =class="tdBody">删除</td> </tr><% rs.movenextnext%></table>循环体结束分页部分:<table width="99%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff><tr><%if rs.pagecount > 0 then%><td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td><%else%><td width="11%" align="left">当前页0/0</td><%end if%><td width="76%" align="right"> <a href="fenye02.asp?page=1">[首页]</a>| <%if pre then%><a href="fenye02.asp?page=<%=intpage -1%>">[上页]</a>| <%end if%><%if last then%><a href="fenye02.asp?page=<%=intpage +1%>">[下页]</a> |<%end if%><a href="fenye02.asp?page=<%=rs.PageCount%>">[尾页]</a>|转到第<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;"><%for i = 1 to rs.PageCountif i = intpage then%><option value="fenye02.asp?page=<%=i%>" selected><%=i%></option><%else%><option value="fenye02.asp?page=<%=i%>"><%=i%></option><%end ifnext%></select>页</font> </td></tr></table></body></html>