寻求一ASP高手在线解决后台分页问题。高分!!!
程序代码:<%sql="fromproductswhere1=1"page_size=20total=conn.Execute("selectCount(*)"&sql)...
程序代码:
<%
sql = "from products where 1=1"
page_size = 20
total = conn.Execute("select Count(*) "&sql)(0)
If total = 0 Then
Response.Write("暂无产品!!")
Else
page = request.QueryString("page")
If page<>"" And IsNumeric(page) Then page = CInt(page) Else page = 1
If total Mod page_size = 0 Then pages = total / page_size Else pages = total \ page_size + 1
If page>pages Then page = pages
If page>1 Then Set rs = conn.Execute("select Top "&page_size&" * "&sql&" and id>(select max(id) from (select top "&page_size * (page -1)&" id "&sql&") as maxId)") Else Set rs = conn.Execute("select Top "&page_size&" * "&sql&"")
Do While Not rs.EOF
%>
中间是表格
<%'以下显示分页
Call PageControl(total, pages, page, "border=0 align=center", "<p align=center>")
%>
可以分页,但是最后两页什么也不显示,如图: 展开
<%
sql = "from products where 1=1"
page_size = 20
total = conn.Execute("select Count(*) "&sql)(0)
If total = 0 Then
Response.Write("暂无产品!!")
Else
page = request.QueryString("page")
If page<>"" And IsNumeric(page) Then page = CInt(page) Else page = 1
If total Mod page_size = 0 Then pages = total / page_size Else pages = total \ page_size + 1
If page>pages Then page = pages
If page>1 Then Set rs = conn.Execute("select Top "&page_size&" * "&sql&" and id>(select max(id) from (select top "&page_size * (page -1)&" id "&sql&") as maxId)") Else Set rs = conn.Execute("select Top "&page_size&" * "&sql&"")
Do While Not rs.EOF
%>
中间是表格
<%'以下显示分页
Call PageControl(total, pages, page, "border=0 align=center", "<p align=center>")
%>
可以分页,但是最后两页什么也不显示,如图: 展开
2011-05-04
展开全部
上面有东西没写完。。。
下面是引用的page.asp的代码
<%
'提示错误信息
Sub strA(str1)
Response.Write("<script language=""JavaScript"">alert("""&str1&""");history.go(-1);</script>")
response.End()
End Sub
'成功提示信息
Sub strB(str2, url)
Response.Write("<script language=""JavaScript"">alert("""&str2&""");window.location='"&url&"';</script>")
response.End()
End Sub
'页面自动跳转
Sub AutoJump(str1, url)
Response.Write("<br/> <font color=red>"&str1&"</font><br/>")
Response.Write("<br/> 正在跳转...<br/>")
Response.Write("<br/> 页面没有自动跳转<a href="&url&">【点这里】</a><br/>")
Response.Write("<meta http-equiv=refresh content=2;url='"&url&"'>")
End Sub
'分页子程序
Sub PageControl(iCount, pagecount, page, table_style, font_style)
'生成上一页下一页链接
Dim query, a, x, temp, action
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
query = Split(Request.ServerVariables("QUERY_STRING"), "&")
For Each x In query
a = Split(x, "=")
If StrComp(a(0), "page", vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next
Response.Write("<table width=100% align=center border=0 cellpadding=0 cellspacing=0 >" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR >" & vbCrLf )
Response.Write("<TD align=left class=hui>" & vbCrLf )
Response.Write(font_style & vbCrLf )
'response.Write "<A href=javascript:history.back()>【返回前页】</a> "
If page<= 1 Then
Response.Write ("首页 " & vbCrLf)
Response.Write ("上一页 " & vbCrLf)
Else
Response.Write("<A HREF=" & action & "?" & temp & "Page=1>首页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page -1) & ">上一页</A> " & vbCrLf)
End If
If page>= pagecount Then
Response.Write ("下一页 " & vbCrLf)
Response.Write ("尾页 " & vbCrLf)
Else
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page + 1) & ">下一页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount & ">尾页</A> " & vbCrLf)
End If
Response.Write("页次:" & page & "/" & pageCount & "页"& vbCrLf)
Response.Write(" 共" & iCount & "条记录" & vbCrLf)
Response.Write(" 转" & "<INPUT CLASS=wenbenkuang TYEP=TEXT NAME=page SIZE=1 Maxlength=5 VALUE=" & page & ">" & "页" & vbCrLf & "<INPUT CLASS=go-wenbenkuang type=submit value=转到>")
Response.Write("</TD>" & vbCrLf )
Response.Write("</TR></form>" & vbCrLf )
Response.Write("</table>" & vbCrLf )
End Sub
Sub Left1(str1, url)
Response.Write("<br/> <font color=red>"&str1&"</font><br/>")
Response.Write("<br/> 正在跳转...<br/>")
Response.Write("<br/> 页面没有自动跳转<a href="&url&">【点这里】</a><br/>")
Response.Write("<meta http-equiv=refresh content=2;url='"&url&"'>")
End Sub
%>
下面是引用的page.asp的代码
<%
'提示错误信息
Sub strA(str1)
Response.Write("<script language=""JavaScript"">alert("""&str1&""");history.go(-1);</script>")
response.End()
End Sub
'成功提示信息
Sub strB(str2, url)
Response.Write("<script language=""JavaScript"">alert("""&str2&""");window.location='"&url&"';</script>")
response.End()
End Sub
'页面自动跳转
Sub AutoJump(str1, url)
Response.Write("<br/> <font color=red>"&str1&"</font><br/>")
Response.Write("<br/> 正在跳转...<br/>")
Response.Write("<br/> 页面没有自动跳转<a href="&url&">【点这里】</a><br/>")
Response.Write("<meta http-equiv=refresh content=2;url='"&url&"'>")
End Sub
'分页子程序
Sub PageControl(iCount, pagecount, page, table_style, font_style)
'生成上一页下一页链接
Dim query, a, x, temp, action
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
query = Split(Request.ServerVariables("QUERY_STRING"), "&")
For Each x In query
a = Split(x, "=")
If StrComp(a(0), "page", vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next
Response.Write("<table width=100% align=center border=0 cellpadding=0 cellspacing=0 >" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR >" & vbCrLf )
Response.Write("<TD align=left class=hui>" & vbCrLf )
Response.Write(font_style & vbCrLf )
'response.Write "<A href=javascript:history.back()>【返回前页】</a> "
If page<= 1 Then
Response.Write ("首页 " & vbCrLf)
Response.Write ("上一页 " & vbCrLf)
Else
Response.Write("<A HREF=" & action & "?" & temp & "Page=1>首页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page -1) & ">上一页</A> " & vbCrLf)
End If
If page>= pagecount Then
Response.Write ("下一页 " & vbCrLf)
Response.Write ("尾页 " & vbCrLf)
Else
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page + 1) & ">下一页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount & ">尾页</A> " & vbCrLf)
End If
Response.Write("页次:" & page & "/" & pageCount & "页"& vbCrLf)
Response.Write(" 共" & iCount & "条记录" & vbCrLf)
Response.Write(" 转" & "<INPUT CLASS=wenbenkuang TYEP=TEXT NAME=page SIZE=1 Maxlength=5 VALUE=" & page & ">" & "页" & vbCrLf & "<INPUT CLASS=go-wenbenkuang type=submit value=转到>")
Response.Write("</TD>" & vbCrLf )
Response.Write("</TR></form>" & vbCrLf )
Response.Write("</table>" & vbCrLf )
End Sub
Sub Left1(str1, url)
Response.Write("<br/> <font color=red>"&str1&"</font><br/>")
Response.Write("<br/> 正在跳转...<br/>")
Response.Write("<br/> 页面没有自动跳转<a href="&url&">【点这里】</a><br/>")
Response.Write("<meta http-equiv=refresh content=2;url='"&url&"'>")
End Sub
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
?geshou=<%=server.URLEncode(Request.Form("geshou"))%>&page=2
将以上参数去掉,添加一个隐藏表单域,<input name='geshou' type='hidden' value='《%=request.form("geshou") %>'>
request.querystring 是用来接收地址里面?后面的xx=xx的内容
而request.form 是用来接收表单递交来的数据
或者你把request.form都改成request()吧。
希望可以帮到你,告诉我你的QQ,我会加你的,我们可以相互学习:)
将以上参数去掉,添加一个隐藏表单域,<input name='geshou' type='hidden' value='《%=request.form("geshou") %>'>
request.querystring 是用来接收地址里面?后面的xx=xx的内容
而request.form 是用来接收表单递交来的数据
或者你把request.form都改成request()吧。
希望可以帮到你,告诉我你的QQ,我会加你的,我们可以相互学习:)
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询