标题:[求助]asp循环中怎样显示序号(非ID)
只看楼主
thbwn
Rank: 1
等 级:新手上路
帖 子:235
专家分:0
注 册:2007-10-2
结帖率:80%
 问题点数:0 回复次数:5 
[求助]asp循环中怎样显示序号(非ID)
asp显示正确序号(编号),现在的代码不分页时按顺序显示,一旦分页,每一页都从1开始排序,怎么弄?


代码:
<%@ codepage=936 %>
<!--#include file="conn.asp"-->
<%
dim i,intPage,page,pre,last,filepath
  set rs = server.CreateObject("adodb.recordset")
   sql="select * from file order by ID desc"
      rs.PageSize = 15         //(HacKpp:这里设定每页显示的记录数
      rs.CursorLocation = 3
      rs.Open sql,conn,0,2,1   //(HacKpp:'这里执行你查询SQL并获得结果记录集
      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.PageCount
                  last = false
              else
                   intpage = cint(page)
             end if
         end if
      end if
    if not rs.eof then
         rs.AbsolutePage = intpage
    end if
%>

<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>查询</title>
<link rel="stylesheet" href="Data\style.css">
</head>
<SCRIPT language=JavaScript type=text/javascript>
function checkclick(msg,url){if(confirm(msg))window.location.href=url;}
function openwin(url,w,h,s){window.open(url,'_blank','status=yes,scrollbars='+s+',top=20,left=110,width='+w+',height='+h);}
</script>
<body style="text-align: center">
<div align="center"><br>
<table class="mian" border="0" cellpadding="1" cellspacing="0">
  <tr>
    <td  class="top">列表</td>
  </tr>
</table>
<br>
<table class="mian" border="0" cellpadding="1" cellspacing="0">
<tr><td align="center">
<table class='Stable' border="0" cellpadding="3" cellspacing="0">
    <TR align="center">
     <th width="5%">序号</th>
      <th>文件名称</th>
      <th width="5%">类型</th>
      <th width="12%">大小</th>
      <th width="20%">上传时间</th>
      <th width="15%">浏览</th>
          </tr>
    <%if rs.EOF or rs.BOF then
     response.write "<TR><td colspan=6 height=20><div align=center>暂时还没有任何上传文件</div></td></TR>"
     end if
     %>
  <%   

   for i=1 to rs.PageSize
     if rs.EOF or rs.BOF then exit for
  %>
<form action="ViewFile.asp" method="post">
<tr align="center">

      <td width="5%" align="center"><%=i%></td>
      <% dim lens
       l1=len(rs("oriname"))
       l2=len(Mid(rs("oriname"),InStrRev(rs("oriname"),".")))
       lens=l1-l2
       leftname=left(rs("oriname"),lens)
       %>
      <td align="center"><% if len(leftname)>20 then response.Write(left(leftname,20)&"…") else response.Write(leftname)%></td>
      <td width="5%" align="center"><img src=<%=rs("type")%>></td>
      <td width="12%" align="center"><%=Split(Rs("contentlen"),".")(0)%>&nbsp;KB</td>
      <td width="20%" align="center"><%=rs("uptime")%></td>
      <td width="15%" align="center"><input type="hidden" name="file" value="<%=rs("fileName")%>"><input type="submit" value="点击浏览"  class="bt"></td>
     
          </tr>
          </form>
    <%  
     rs.movenext
    next
   %>
  </table>
</td></tr></table>
<center>
  <table width="650" border="0" cellpadding="3" cellspacing="1" borderColorLight=#808080 borderColorDark=#ffffff>
   <tr>
     <%if rs.pagecount > 0 then%>
     <td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
     <%else%>
    <td width="40%" align="left">当前页0/0</td><%end if%>
    <td width="47%" align="right"> <a href="index.asp?page=1">首页</a> |
     <%if pre then%>
     <a href="index.asp?page=<%=intpage -1%>">上页</a> | <%end if%>
     <%if last then%>
      <a href="index.asp?page=<%=intpage +1%>">下页</a> |<%end if%>
      <a href="index.asp?page=<%=rs.PageCount%>">尾页</a> | 转到第
      <select name="sel_page" onChange="javascript:location=this.options[this.selectedIndex].value;">
      <%
       for i = 1 to rs.PageCount
       if i = intpage then%>
       <option value="index.asp?page=<%=i%>" selected><%=i%></option>
     <%else%>
       <option value="index.asp?page=<%=i%>"><%=i%></option>
        <%
          end if
        next
        %>
     </select>页</font>
    </td>
    </tr>
   </table>
  </center>
</div>
</body>
</html>

[ 本帖最后由 thbwn 于 2010-8-29 12:25 编辑 ]
搜索更多相关主题的帖子: 序号 asp 
2010-08-29 11:43
cnfarer
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:179
帖 子:3330
专家分:21157
注 册:2010-1-19
得分:0 
<%=i%>---><%=(intpage*rs.pagesize+i)%>

★★★★★为人民服务★★★★★
2010-08-29 13:26
wangjy500
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:13
帖 子:457
专家分:2569
注 册:2010-7-11
得分:0 
<%=i%>---><%=((intpage-1)*rs.pagesize+i)%>

QQ:63572063
2010-08-29 18:26
hams
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:18
帖 子:912
专家分:3670
注 册:2008-7-30
得分:0 
每页数量*(页数-1)+i

俺不高手,俺也是来学习的。
俺的意见不一定就对,当你不认同时请点忽视按钮。
当走到十字路口不知该如何走时,可在论坛问下路,但你若希望别人能一路把你送到目的地,显然是不现实的,因为别人也有自己要走的路。
2010-08-30 08:31
towering
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:261
专家分:507
注 册:2007-10-9
得分:0 
个人感觉可以用ol来实现

我的ASP小站:http://www./
2010-09-01 14:13
thbwn
Rank: 1
等 级:新手上路
帖 子:235
专家分:0
注 册:2007-10-2
得分:0 
序号
(rs.AbsolutePage-1)*rs.PageSize+i   解决

          人人为我,我为人人!
2010-09-01 23:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-317104-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019520 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved