asp分页问题,求高手解答

作者&投稿:古祁 (若有异议请与网页底部的电邮联系)
ASP分页问题??~

给我一直在用的一个分页函数给你
'PID 页面中的其它传参连接
'page 要显示的页码
'Vcount 总记录数
'Pnum 每页记录数
'className 超连接样式
public function ThePage(Pid,page,Vcount,Pnum,className)
dim show
page = int(page)
Pcount = abs(int(-abs(Vcount/Pnum)))
if page = "" or page <= 0 then page = 1
if page>Pcount then page=Pcount
StartPageNum=1
do while StartPageNum+10<=page
StartPageNum=StartPageNum+10
Loop
EndPageNum=StartPageNum+9
If EndPageNum>Pcount then EndPageNum=Pcount
show = show&""
show = show&"共"&Pcount&"页 共有"&Vcount&"记录 第"&page&"页 跳到第 [ "
if StartPageNum>1 then
show = show&"7"
end if
For go=StartPageNum to EndPageNum
if gopage then
show = show&""&go&""
else
show = show&""&go&""
end if
show = show&" "
Next

if EndPageNum<Pcount then
show = show&"8"
end if
show = show& "] 页"

if page1 then
show = show&" 首页 上一页"
end if
if Pcount-page 0 then
show = show& " 下一页 尾页"
end if
show=show&""
ThePage = show
end function
=====================使用示例============================
<%
'分页参数设置
sql = "select * from [guestbook] order by orderid,id desc"
page = GQ("page",1)
page = int(page)
Pnum = 15
className = "lwf"
PID = ""
'以下不变
set rs = DB.S(SQL,1)
Vcount = RS.recordcount
if RS.recordcount 0 then
RS.absoluteposition=RS.absoluteposition+((abs(page)-1)*Pnum)
end if
'********************************
i = 1
while not RS.eof and i<=Pnum
%>








<%
rs.movenext
i = i + 1
wend
rs.close
set rs = nothing
%>

===================分页样式 ==================================

div.pagination {
margin: 50px 15px 50px 0 ;
text-align:center;
clear:both;
}

div.pagination a {
border: 1px solid #5a5a5a;
margin-right:3px;
padding:2px 6px;
font-family:"宋体";
background-position:bottom;
text-decoration: none;
color: #fff;
}
div.pagination a:hover, div.meneame a:active {
background-image:none;
background-color:#dd4b2f;
color: #fff;
text-decoration:none;
}
div.pagination span.current {
margin-right:3px;
padding:2px 6px;
background-color:#dd4b2f;
font-weight: bold;
border: 1px solid #5a5a5a;
color: #fff;
}
div.pagination span.disabled {
margin-right:3px;
padding:2px 6px;
border: 1px solid #5a5a5a;
color: #000;
background-color:#fff;
}


给我一直在用的一个分页函数给你

'PID 页面中的其它传参连接
'page 要显示的页码
'Vcount 总记录数
'Pnum 每页记录数
'className 超连接样式
public function ThePage(Pid,page,Vcount,Pnum,className)
dim show
page = int(page)
Pcount = abs(int(-abs(Vcount/Pnum)))
if page = "" or page <= 0 then page = 1
if page>Pcount then page=Pcount
StartPageNum=1
do while StartPageNum+10<=page
StartPageNum=StartPageNum+10
Loop
EndPageNum=StartPageNum+9

If EndPageNum>Pcount then EndPageNum=Pcount
show = show&""
show = show&"共"&Pcount&"页 共有"&Vcount&"记录 第"&page&"页 跳到第 [ "
if StartPageNum>1 then
show = show&"7"
end if
For go=StartPageNum to EndPageNum

if gopage then
show = show&""&go&""
else
show = show&""&go&""
end if
show = show&" "
Next

if EndPageNum<Pcount then
show = show&"8"
end if
show = show& "] 页"

if page1 then
show = show&" 首页 上一页"
end if

if Pcount-page 0 then
show = show& " 下一页 尾页"
end if
show=show&""
ThePage = show
end function

=====================使用示例============================
<%
'分页参数设置
sql = "select * from [guestbook] order by orderid,id desc"
page = GQ("page",1)
page = int(page)
Pnum = 15
className = "lwf"
PID = ""
'以下不变
set rs = DB.S(SQL,1)
Vcount = RS.recordcount
if RS.recordcount 0 then
RS.absoluteposition=RS.absoluteposition+((abs(page)-1)*Pnum)
end if

'********************************
i = 1
while not RS.eof and i<=Pnum

%>









<%
rs.movenext
i = i + 1
wend
rs.close
set rs = nothing
%>

<body>
<!--#include file="inc/logotop.asp" -->
<!--#include file="inc/sys.asp"-->
<%
sub titlen(i)
tlen=rs("topic")
if len(tlen)>i then
tlen=left(tlen,i)&"..."
else
tlen=tlen
end if
end sub
'设置每页显示数量
Const PAGESIZE=8
'设置略显示多少页
Const PARTSIZE=10
dim tlen
tlen=""
AProductClass=trim(request("ProductClass"))
dim pagecount,page,Spage,Epage,recordcount,i
page = request.querystring("page")
if page = "" or IsNull(page) then page = 1
if not IsNumeric(page) then page = 1
page = Cint(page)
%>

<%
call checkform()
ProductClass=request("ProductClass")
ClassName=request("ClassName")

if productclass = "" then
set rsc=conn.execute("select top 1 * from tproductclass where ver=0 order by sortno")
call DoError()
if not rsc.eof then
productclass = rsc("classid")
classname = rsc("classname")
end if
rsc.close()
set rsc = nothing
end if

sql = "select * from tproduct where ver=0 "
if ProductClass <> "" then
sql = sql & " and ProductClass="&cstr(ProductClass)
end if
sql = sql & " order by sortno"
rs.open sql,conn,1,1
recordcount = RS.RecordCount
RS.PageSize = PAGESIZE
pagecount = RS.PageCount
if page < 1 then
page = 1
elseif page > pagecount then
page = pagecount
end if
if RS.EOF then
Response.Write("<center><font color=red>目前还没有内容</font>")
else
if recordcount > 0 then RS.AbsolutePage = page
call DoError()
%>

<!--#include file="inc/left_tel.asp" --></td>
</tr>
</tbody>
</table>
<p> </p></td>
<td width="619" align="center" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" bgcolor="#f1f1f1" class="td_nybt">
<img src="images/bullet_snav_cap.gif" width="12" height="12"> <%=classname%> </td>
</tr>
<tr>
<td height="1" bgcolor="#666666"></td>
</tr>
</table>
<br>

<TABLE width=94% height="117" border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<%
for i = 1 to PAGESIZE
if RS.EOF then exit for
call titlen(listlen)
%>
<TR vAlign=middle align=left>
<TD height="115" align="left"><a href="product_detail.asp?productid=<%=rs("productid")%>"><img src="product/<%=rs("defaultpicurl")%>" width=152 height=140 border="0"></a></TD>
<% call DoError() %>
<TD><table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="69%" height="22"><strong> <%=rs("productname")%></strong></td>
<td width="31%"><a href="product_detail.asp?productid=<%=rs("productid")%>"><img src="images/PRODUCT/title_news.gif" width="70" height="23" border="0"></a></td>
</tr>
<tr>
<td colspan="2" class="td1en"><%=rs("summary")%></td>
</tr>
</table></TD>
</TR>
<TR>
<TD width=28% height="1" bgcolor="#E2E7EA"></TD>
<TD width=72% height="1" bgcolor="#E2E7EA"></TD>
</TR>
<%
rs.movenext
next
rs.close
set rs = nothing
%>
</TBODY>
</TABLE>
<br>
<%if pagecount > 0 then
response.write("<table width=""95%"" align=center cellspacing=3 cellpadding=3><tr><td align=right>")
response.write("页次:<font color=red><b>" & page & "</font>/" & pagecount & "</b>  每页<b>" & pagesize & "</b>  共<b>" & recordcount & "</b>  条:")
Spage = page mod PARTSIZE
if page > PARTSIZE then
if Spage = 0 then Spage = PARTSIZE
Spage = page - Spage + 1
else
Spage = 1
end if
Epage = Spage + PARTSIZE - 1
if Epage > pagecount then Epage = pagecount
if page > PARTSIZE then
response.write("<a href=""?d_id="&d_id&"&ProductClass=" & AProductClass & "&page=" & Spage - 1 & """>[<<]</a>")
end if
for i = Spage to Epage
if i = page then
response.write("[<font color=red><b>" & i & "</b></font>]")
else
response.write("[<a href=""?d_id="&d_id&"&ProductClass=" & AProductClass & "&page=" & i & """>" & i & "</a>]")
end if
next
if Epage < pagecount then
response.write("<a href=""?d_id="&d_id&"&ProductClass=" & AProductClass & "&page=" & Epage + 1 & """>[>>]</a>")
end if
if Spage <> 1 then response.write("[<a href=""?d_id="&d_id&"&ProductClass=" & AProductClass & "&page=1"">首页</a>]")
if Epage <> pagecount then response.write("[<a href=""?d_id="&d_id&"&ProductClass=" & AProductClass & "&page=" & pagecount & """>尾页</a>]")
response.write("</td></tr></table><br>")
end if
rs.close
set rs=nothing
%>
</td>
<td width="1" bgcolor="#D6D6D6"></td>
</tr>
</table>
</td>
</tr>
</table>
<!--#include file="inc/foot.asp" -->
</body>
</html>
<!--#include file="inc/kefu_index.asp"-->
<%
set rsss=nothing
set rss=nothing
set rs=nothing
set conn=nothing
%>

你自己测试一下,有问题给我留言。

真正

asp分页问题,点下一页,id号丢失,应该怎么写?求高手解答
答:end if if k<>objRS.PageCount then response.write "["+"下一页] "response.write "["+"尾页] "else Response.Write "[下一页] [尾页]"end if 把分也代码修改一下就好了,上面的分页代码是我改完的,你可以直接复制到你的原代码里看看好不好用。

asp分页问题,求高手解答
答: <!--#include file="inc/logotop.asp" --> <!--#include file="inc/sys.asp"--> < sub titlen(i)tlen=rs("topic")if len(tlen)>i then tlen=left(tlen,i)&"..."else tlen=tlen end if end sub '设置每页显示数量 Const PAGESIZE=8 '设置略显示多少页 Const PARTSIZE=10 dim...

asp问题,求高手解答
答:按自己的理解。1.作用域分为局部和全局。(这个很容易理解,比方,你在asp页面里面:dim a 这时,如果你在另一个页面里就找不到此变量a ,全局,即不管什么页面都可以获得,分为application对象和session对象,都可以用来实现全局)生命周期,我觉得的是vbscript当中的function 函数之流的逻辑顺序。2.requ...

求高手帮忙解决ASP程序问题?
答:驱动程序不支持所需的属性,按这个提示来看,你61行应该是rst.open sql,conn,1,1 这一行代码吧。sql是一个简单的Sql语句。检查一下你有没有shop这个表,表里面有没有ID 这个字段。如果不是这一行。请把第61行代码标识出来。还有,如楼上说的,Set Rst = myPagination.rst 这个不知道你是要做什...

求ASP高手解答
答:strname=Request.Form("username")strhomepage=Request.Form("homepage")stremail=Request.Form("Email")Set FileSystemobject=Server.CreateObject("Scripting.FileSystemObject")voteincdir = server.mappath("test.txt")Const ForReading =1, ForWriting = 2 set fs = CreateObject("Scripting....

会ASP的高手请帮我解答,谢谢
答:首先 你的应该不是表 是字段 你用下面这代码试试 <% if rsweb("GAME_in_date") >rsweb("GAME_out_date") then response.write "在线"else response.write "离线"end if >

求asp.net高手帮忙解答问题!!
答:A、aspx B、vb C、naster(这个有问题,应该是master) D、asp 9、OLE DB的.NET数据提供者的类位于___D___命名空间下。A、System.Data B、System.Data.ODBC C、System.Data.sql D、System.Data.OleDb 6、对于文件上传控件FileUpload,FileUploadl.PostedFile.FileName表示的是( ...

求教高手下 ASP的问题
答:判断数据库是否为空,要判断BOF和EOF属性是否同时为空,你只是判断游标是否位于最后一条记录之后就认定是没有记录,这样在判断不严谨 但你这儿的用法并不一定报错,如果游标类型"只读向前"从开始读取到EOF为真时,可以判断数据库为空,如果非"只读向前"类型游标,那么当我调用MOVEFIRST方法时,你仍按上述方法...

ASP程序问题,急,求高手解答
答:贴了大段代码,问题和错误是什么?这种程序很简单呀,就是一个循环。

asp.net 调用 存储过程的问题
答:这个里面的exec不用加,加了有问题了 传参的话 如果是输出参数的可以先写一下 比方说查个总记录条数 SqlParameter outPara = new SqlParameter();sp.ParameterName = "@ResCnt";//参数名 sp.DbType = DbType.Int32;//类型 sp.Direction = ParameterDirection.Output;//方向 SqlParameter[] args...