首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

asp分页时记录会不出现!解决办法

2012-02-16 
asp分页时记录会不出现!!!如:数据库有12条记录,分页时pagesize10,在分页时第一页正常,单击下一页时,剩余

asp分页时记录会不出现!!!
如:数据库有12条记录,分页时pagesize=10,在分页时第一页正常,单击下一页时,剩余的记录竟然不会出现,只显示为空,请问高手这是什么原因?
<%@   CODEPAGE= "936 "%>
<!--#include   file= "../inc/includeTeacher.asp "-->
<%
      dim   teachingplanID,teachingGrade,teachingSubject,Page,sql
     
      teachingGrade=trim(request( "teachingGrade "))
      teachingSubject=trim(request( "teachingSubject "))
      Page=cint(trim(request.QueryString( "page ")))
      if   Page <=0   then
            Page=1
      end   if
      sql= "select   *   from   teachingplan   where   teachingplanID> 0 "
      if   teachingGrade <> " "   then
            sql=sql   &   "and   teachingGrade= ' "   &   teachingGrade   &   " ' "
      end   if
      if   teachingSubject <> " "   then
    sql=sql   &   "and   teachingSubject= ' "   &   teachingSubject   &   " '   "
      end   if      
      sql=sql   &   "   order   by   teachingplanID   asc " 'desc降序asc升序
      set   rs=createobject( "adodb.recordset ")      
      rs.open   sql,conn,1,1
     
%>
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> 备课系统 </title>
<style   type= "text/css ">
<!--
.TableLine   {
border:   1px   solid   #6BC804;
margin:   1px;
width:   auto;
}
-->
</style>
</head>

<body   background= "image/bg.gif "   link= "#669933 "   vlink= "#669933 "   alink= "#669933 ">
<div   align= "center ">   </div>
    <div   align= "center ">   <br>
        <br>
    </div>
   
<div   align= "center "> <font   color= "#669933 "   size= "5 "> <strong> <img   src= "image/teachingplan_list.gif "   width= "165 "   height= "61 "> </strong> </font>  
</div>  
</div>
<table   width= "100% "   border= "0 "   align= "center "   cellpadding= "0 "   cellspacing= "1 "   class= "TableLine ">
    <tr>  
        <td   width= "55 "   background= "image/table_bg.gif ">   <div   align= "center "> <font   color= "#669933 "   size= "2 "> 选中 </font> </div> </td>
        <td   width= "55 "   background= "image/table_bg.gif ">   <div   align= "center "> <font   color= "#669933 "   size= "2 "> ID </font> </div> </td>


        <td   width= "31% "   height= "20 "   background= "image/table_bg.gif ">  
            <div   align= "center "> <font   color= "#669933 "   size= "2 "> 课题 </font> </div> </td>
        <td   width= "96 "   height= "20 "   background= "image/table_bg.gif ">   <div   align= "center "> <font   color= "#669933 "   size= "2 "> 册数 </font> </div> </td>
        <td   width= "96 "   background= "image/table_bg.gif ">   <div   align= "center "> <font   color= "#669933 "   size= "2 "> 备课教师 </font> </div> </td>
        <td   width= "125 "   height= "20 "   background= "image/table_bg.gif ">   <div   align= "center "> <font   color= "#669933 "   size= "2 "> 备课时间 </font> </div> </td>
        <td   width= "108 "   height= "20 "   background= "image/table_bg.gif ">   <div   align= "center "> <font   color= "#669933 "   size= "2 "> 审核状态 </font> </div> </td>
        <td   width= "89 "   background= "image/table_bg.gif ">   <div   align= "center "> <font   color= "#669933 "   size= "2 "> 登录 </font> </div> </td>
        <td   width= "154 "   background= "image/table_bg.gif ">   <div   align= "center "> <font   color= "#669933 "   size= "2 "> 功能设置 </font> </div> </td>
    </tr>
    <tr>  
        <td   colspan= "9 ">   <%  
 
  IF   not(rs.bof   and   rs.eof)   THEN
                  PageList=10 '每页显示的记录总数
MaxPageCount=rs.pagecount '最大页数(变量)=总页数
TotalRecordCount=cint(rs.recordCount) '统计记录总数变量    
RecordList=0 '记录数变量            
rs.absolutepage=page '当前页数
                do   while   not(rs.eof)   and   RecordList   <   PageList      
      %>   </td>
    </tr>
    <tr>  
        <td   height= "26 ">   <div   align= "center ">  
                <input   name= "chkSelect "   type= "checkbox "   id= "chkSelect "   value= "checkbox ">
            </div> </td>
        <td   height= "26 "> <div   align= "center "> <font   color= "#333333 "   size= "2 "> <%=rs( "teachingplanID ")   %>   </font> </div> </td>
        <td   height= "26 ">   <font   color= "#333333 "   size= "2 "> <%=rs( "teachingTitle ")   %>   </font> </td>


        <td   height= "26 "> <div   align= "center "> <font   color= "#333333 "   size= "2 "> <%=rs( "teachingBook ")   %>  
                </font> </div> </td>
        <td   height= "26 "> <div   align= "center "> <font   color= "#333333 "   size= "2 "> <%=rs( "teacher ")   %> </font> </div> </td>
        <td   height= "26 "> <div   align= "center "> <font   color= "#333333 "   size= "2 "> <%=rs( "teachingTime ")   %> </font> </div>
            </td>
        <td   height= "26 "> <div   align= "center "> <font   color= "#333333 "   size= "2 "> <%=rs( "teachingplanPass ")   %> </font> </div> </td>
        <td   height= "26 "> <div   align= "center "> <font   color= "#333333 "   size= "2 "> <%=rs( "Counter ")   %> </font> </div> </td>
        <td   height= "26 "> <font   color= "red "   size= "2 ">  
            <div   align= "center ">   <a   href=modifyteachermanager.asp?teacherID= <%=rs( "teacherID ")%> &modifyIdentity= <%=   rs( "teacherIdentity ")%> >  
                <img   src= "image/modify.gif "   border= "0 "> </a>   <a   href=ManagerDelTeacher.asp?teacherID= <%=rs( "teacherID ")%> &delIdentity= <%=   rs( "teacherIdentity ")%> &controlIdentity= <%=session( "teacherIdentity ")%>   onClick= 'return     confirm( "提示:确认删除该教师记录吗? "); '>  
                <img   src= "image/del.gif "   border= "0 "> </a>   </div>
            </font> </td>
    </tr>
    <tr>  
        <td   height= "1 "   colspan= "9 "> </td>
    </tr>
    <%  
            rs.movenext                        
            RecordList=RecordList+1  
            loop
    set     rs=nothing    
    ELSE
            response.Write( "正在添加中... "   )
        END   IF  
    %>
    <%
        pageBack=page                  
        pageNext=page                  
          '上一页和下一页
if   pageBack=1   then


              pageBack=1
      pageNext=pageBack+1
        else  
pageBack=pageBack-1
        pageNext=pageBack+2
        if   pageNext> MaxPageCount   then   '如果下一页大于最大页数,下一页就等于最大页数
      pageNext=MaxPageCount
end   if
        end   if                
    %>
    <tr>  
        <td   height= "26 "   colspan= "9 "   > <div   align= "center "> <font   color= "#333333 "   size= "2 ">  
                学校教师总人数: <font   color= "red "> <%=TotalRecordCount%> </font>  每页显示: <font   color= "red "> <%=PageList%> </font>  当前页数: <font   color= "red "> <%=Page%> </font> / <%=MaxPageCount%> </font> <font   size= "2 ">   <a   href= "teachingplanList.asp?teachingGrade= <%=teachingGrade%> &teachingSubject= <%=teachingSubject%> &page= <%=Pageback%> "> <img   src= "image/backpage.jpg "   width= "45 "   height= "18 "   border= "0 "   align= "absmiddle "> </a> </font>  
                <a   href= "teachingplanList.asp?teachingGrade= <%=teachingGrade%> &teachingSubject= <%=teachingSubject%> &page= <%=pageNext%> "> <img   src= "image/nextpage.jpg "   width= "45 "   height= "18 "   border= "0 "   align= "absmiddle "> </a>  
            </div> </td>
    </tr>
</table>
<div   align= "center "> </div>
</body>
</html>


[解决办法]
你指定了rs.pagesize 吗?
[解决办法]
Dim RowCount
RowCount = 10 '每页显示的记录条数
Dim TotalPage '总页数
Dim PageNo '当前显示的是第几页
Dim RecordC '总记录条数
Rs.PageSize = RowCount
RecordC = Rs.RecordCount
TotalPage =Rs.pagecount
'TotalPage =INT(RecordC/PageSize * -1)*-1
PageNo = Request.QueryString ( "PageNo ")
'直接输入页数跳转;
If Request.Querystring( "PageNo ") <> " " Then PageNo = Request.Querystring( "PageNo ")
'如果没有选择第几页,则默认显示第一页;
If PageNo = " " then PageNo = 1
If RecordC <> 0 then
Rs.AbsolutePage = PageNo
End If

[解决办法]
可以用啊,我测试过的
不过我在
Page=cint(trim(request.QueryString( "page ")))
前面加了一句
if request.QueryString( "page ") <> " " and isnumeric(request.QueryString( "page ")) then
Page=cint(trim(request.QueryString( "page ")))
end if

你这个不分页不怎么好,很多地方写的太浪费了,譬如上一页 ,下一页的参数
[解决办法]
在 <% %> 里加上 rs.PageSize = 10;
rs.AbsolutePage = Page;
------解决方案--------------------


沒有指定rs.absolutepage當前頁面和rs.pagesize頁面大小
應該在讀取分頁數據前進行這兩個內容設置

热点排行