| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3038 人关注过本帖
标题:[求助]asp循环中怎样显示序号(非ID)
取消只看楼主 加入收藏
thbwn
Rank: 1
等 级:新手上路
帖 子:235
专家分:0
注 册:2007-10-2
结帖率:80%
收藏
 问题点数:0 回复次数:1 
[求助]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
thbwn
Rank: 1
等 级:新手上路
帖 子:235
专家分:0
注 册:2007-10-2
收藏
得分:0 
序号
(rs.AbsolutePage-1)*rs.PageSize+i   解决

          人人为我,我为人人!
2010-09-01 23:35
快速回复:[求助]asp循环中怎样显示序号(非ID)
数据加载中...
 
   



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

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