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

分页的写法有关问题,没有思路了,一下,或是帮改一下~

2012-03-01 
求一个分页的写法问题,没有思路了,高手指点一下,或是帮改一下~~........ifisno orisno1 thensqlzj

求一个分页的写法问题,没有思路了,高手指点一下,或是帮改一下~~
........

if   isno   =   " "   or   isno   =   "1 "   then  
sql   =   "zjreport   "   &   cname   &   ", "   &   sdate   &   ", "   &   edate
elseif   isno   =   "2 "   then
sql   =   "   zjreport_case   "   &   cname   &   ", "   &   sdate   &   ", "   &   edate
end   if
'response.write   sql
rs.open   sql,conn,3,1

if   rs.eof   then
response.write   " <tr   bgcolor=#ebe9ed> <td   colspan=18> <hr   size=1> <font   color=#FF0000> 没有符合条件的记录,请再次确认您的检索条件! </font> </td> </tr> </table> "
response.end
end   if
PageSize   =   request.Cookies( "PageSize ")
if   not   IsNot(PageSize, "n ")   then   PageSize   =   DefaultPageSize
rs.pagesize   =   PageSize
PageCount   =   rs.PageCount
PageNo   =   request( "PageNo ")
if   PageNo   =   " "   or   CInt(PageNo)   <   1   then   PageNo   =   1
if   CInt(PageNo)   >   PageCount   then   PageNo   =   PageCount

rs.absolutepage   =   PageNo


'------------------------------共用的显示代码(代码本身无错,调试好了)
if   not   rs.eof   then  
          %>
          <tr>
       
                <%for   x=0   to   rs.fields.count-1%>
                <td   class=LoginButtom> <%response.write   rs.fields(x).name%>
                    &nbsp; </td>
                <%next%>
        </tr>
            <%
i   =   0
while   not   rs.eof   and   i   <   rs.pagesize
 
    %>
            <tr>
                <%for   x=0   to   rs.fields.count-1%>
                <td   height= "29 "   class= "bluefont "> <%response.write   rs.fields(x).value%> </td>
                <%next%>
            </tr>
            <%
    rs.movenext
i   =   i   +   1
wend

end   if
    %>
    <%
rs.close
set   rs   =   nothing
conn.close
set   conn   =   nothing
%>
'--------------------------
</table>
<table     class=MainBlock   cellSpacing=0   cellPadding=0   width= "95% "   border=0   align= "center "   >
  <tr     align= "right "   >  


        <td   height= "20 "   colspan= "3 "     bgcolor= "#f3f3f3 "   class= "STYLE1 ">  
            <a   href= "casereport.asp?PageNo=1 "> 第一页 </a>
    <a   href= "casereport.asp?PageNo= <%=   PageNo   -   1   %> "> 上一页 </a>
    <a   href= "casereport.asp?PageNo= <%=   PageNo   +   1   %> "> 下一页 </a>
    <a   href= "casereport.asp?PageNo= <%=   PageCount   %> "> 最后一页 </a>  
    当前位置: <%=PageNo%> / <%=PageCount%> &nbsp;&nbsp;&nbsp;&nbsp; </td>
    </tr>
</table>


........

上面是我的代码,在一个页面中,有一个搜索的选项,可以选择 "大类搜索 "(isno=2)   或是 "小类搜索 "(isno=0   or   isno   = " ")   ,选择不同的搜索类别对应执行的存储过程会不同,如上所示:
if   isno   =   " "   or   isno   =   "1 "   then  
sql   =   "zjreport   "   &   cname   &   ", "   &   sdate   &   ", "   &   edate
elseif   isno   =   "2 "   then
sql   =   "   zjreport_case   "   &   cname   &   ", "   &   sdate   &   ", "   &   edate
end   if
'response.write   sql
rs.open   sql,conn,3,1

然后他们共用一个显示字段值的详细信息的一段代码和分页代码,现在的问题是:
当我作默认选择时,也就是小类搜索时,显示的内容是正常的,分页的数据也是正常的,没有问题;但当我选择 "大类搜索 "后,第一页显示的内容也是正常没有问题的,但是无法正常的分页显示第2,3....页的数据,而是显示的小类搜索的内容,头脑有些乱,不清楚要如何改了,才能保证二者共用一个显示和一个分页代码而能够按需求显示相关内容~~~
求高人指点~~~

[解决办法]
把类别参数传到分页里去。就OK了。
[解决办法]
http://www.sosuo8.com/article/show.asp?id=160
ASP最简单分页我调试的....
[解决办法]
你翻页的时候要传参,丢失和查询数据有关的参数当然记录集不正确。

你可以输出SQL语句和参数变量看看哪里出问题
[解决办法]
http://blog.csdn.net/itzhiren

里面归纳了几种分页的写法
[解决办法]
第一页,上一页,下一页,最后一页都要写,你写了没有
?
[解决办法]
我知道问题出在 选择搜索 “大类”即 isno = "2 " 第一次 是搜索 isno= "2 "的,所以第一页是正确结果,但点 第二页、第三页时 表单只传送了 PageNo 的值 "2 "、 "3 ",而没有把 搜索类型传送,所以 isno会为空,从而恢复搜索默认 的 isno= " "的结果了。

解决:


<table class=MainBlock cellSpacing=0 cellPadding=0 width= "95% " border=0 align= "center " >
<tr align= "right " >
<td height= "20 " colspan= "3 " bgcolor= "#f3f3f3 " class= "STYLE1 ">

<!-- 显示页面切换时,增加一个传送参数 isno -->

<a href= "casereport.asp?PageNo=1&isno= <%=isno%> "> 第一页 </a>
<a href= "casereport.asp?PageNo= <%= PageNo - 1%> &isno= <%=isno% "> 上一页 </a>
<a href= "casereport.asp?PageNo= <%= PageNo + 1%> &isno= <%=isno% "> 下一页 </a>
<a href= "casereport.asp?PageNo= <%= PageCount%> &isno= <%=isno% "> 最后一页 </a>



当前位置: <%=PageNo%> / <%=PageCount%> &nbsp;&nbsp;&nbsp;&nbsp; </td>
</tr>
</table>


[解决办法]
对不起,还要在开头代码中修改一下,以便接收 传来的参数:
........

isno=request.querystring( "isno ") '接收传来的参数

if isno = " " or isno = "1 " then
sql = "zjreport " & cname & ", " & sdate & ", " & edate
elseif isno = "2 " then
sql = " zjreport_case " & cname & ", " & sdate & ", " & edate
end if
'response.write sql
rs.open sql,conn,3,1

[解决办法]
有办法呀,改为

isno = request( "isno ")

iis会自动判断是表单提交的还是URl传值得,其中前者优先级高于后者。

热点排行