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

ASP怎样可以按指定的内容来进行分页显示?该怎么解决

2012-02-19 
ASP怎样可以按指定的内容来进行分页显示?大家好,请问ASP怎样可以按指定的内容来进行分页显示?如:有一个表t

ASP怎样可以按指定的内容来进行分页显示?
大家好,请问ASP怎样可以按指定的内容来进行分页显示?
如:有一个表teachingplan,表中有ID(自动编号),teachingSubject(有:语文、音乐两个学科),text(这是内容)三个字段;有一个下拉列表(单击可以选择相应的学科,如:语文、音乐)。
对它们进行分页显示,但就把整个表的内容进行了分页,我想单击下拉列表的音乐,那么它只能对表中的音乐学科的内容进行分页,而不是整个表的内容来分页,请问怎样写代码?


[解决办法]
<select name= "Subtype " onChange= "location.href= '?subtype= '+this.Options[this.SelectedIndex].value ">
<option value= "请选择 "> 请选择 </option>
<option value= "音乐 "> 音乐 </option>
<option value= "语文 "> 语文 </option> (也可以直接从数据库中掉,注意用distinct避免重复)

然后就可以获取值了
Dim SubType
SubType=Reuqest.QueryString( "subType ")
SQL= "select * from [teachingplan] where teachingSubject= ' "&SubType& " ' "
下面执行Sql语句分页显示结果就不用写了吧..............
[解决办法]
分页的东西 好象不少地方讨论嘛~
一般对所有内容分页就是直接 ***.asp?page=1
对指定内容分页无非就是***.asp?page=1&type=**

给你一个我以前常用的分页代码~
:分页函数~
sub showpage(fl,sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
dim n, i,strTemp,strUrl
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
strTemp= " <table align= 'center '> <tr> <td class= 'pw '> "
if ShowTotal=true then
strTemp=strTemp & "共 <b> " & totalnumber & " </b> " & strUnit & "&nbsp;&nbsp; "
end if
strUrl=JoinChar(sfilename)
if CurrentPage <2 then
strTemp=strTemp & "首页 上一页&nbsp; "
else
strTemp=strTemp & " <a href= ' " & strUrl & "page=1&fcategoryid= "&fl& " ' class= 'lb '> 首页 </a> &nbsp; "
strTemp=strTemp & " <a href= ' " & strUrl & "page= " & (CurrentPage-1) & "&fcategoryid= "&fl& " ' class= 'lb '> 上一页 </a> &nbsp; "
end if

if n-currentpage <1 then
strTemp=strTemp & "下一页 尾页 "
else
strTemp=strTemp & " <a href= ' " & strUrl & "page= " & (CurrentPage+1) & " &fcategoryid= "&fl& " ' class= 'lb '> 下一页 </a> &nbsp; "
strTemp=strTemp & " <a href= ' " & strUrl & "page= " & n & "&fcategoryid= "&fl& " ' class= 'lb '> 尾页 </a> "
end if
strTemp=strTemp & "&nbsp;页次: <strong> <font color=red> " & CurrentPage & " </font> / " & n & " </strong> 页 "
strTemp=strTemp & "&nbsp; <b> " & maxperpage & " </b> " & strUnit & "/页 "
if ShowAllPages=True then
strTemp=strTemp & "&nbsp;转到: <select name= 'page ' size= '1 ' onchange= " "javascript:window.location= ' " & strUrl & "fcategoryid= "&fl& "&page= " & " '+this.options[this.selectedIndex].value; " "> "
for i = 1 to n
strTemp=strTemp & " <option value= ' " & i & " ' "
if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
strTemp=strTemp & "> 第 " & i & "页 </option> "


next
strTemp=strTemp & " </select> "
end if
strTemp=strTemp & " </td> </tr> </table> "
response.write strTemp
end sub


这里的fcategoryid就是上面的那个type 自己改命名~
这里的fl就是要传的值~ 你自己应该明白
调用的时候:

<%showpage request( "fcategoryid "),strFileName,totalput,MaxPerPage,true,true, "个产品 "%>


关于搜索显示部分:

<%

strFileName= "cplist.asp "

const MaxPerPage=20


sql = "select * from table where fcategoryid= "&request( "fcategoryid ")& " "
if request( "page ") <> " " then
currentPage=cint(request( "page "))
else
currentPage=1
end if
'response.write sql
Set rsArticleList= Server.CreateObject( "ADODB.Recordset ")
rsArticleList.open sql,conn,1,1
if rsArticleList.eof and rsArticleList.bof then

response.write " <p align= 'center '> <br> 没有搜索到任何相关信息! <br> </p> "

else
totalPut=rsArticleList.recordcount
if currentpage <1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage> totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
housepage
else
if (currentPage-1)*MaxPerPage <totalPut then
rsArticleList.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rsArticleList.bookmark
showContent
housepage
else
currentPage=1
showContent
housepage
end if
end if
end if
rsArticleList.close
set rsArticleList=nothing
sub showcontent%>
<tr>
<td width= "96% "> <table width= "108 " height= "81 " border= "0 " align= "center " cellpadding= "7 " cellspacing= "0 " class= "ziti ">
<%
n=0
num=0
do while not rsArticleList.eof and num < 30
n=n+1
%>
<% if num mod 5=0 then response.write " <TR> "%>
<td width= "92 ">
<table width= "79% " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td> <div align= "center ">
<table width= "125 " height= "125 " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td align= "center " valign= "middle " background= "image/biank.gif "> <a href= "cp.asp?pid= <%=rsArticleList( "proid ")%> "> <img src= "klmanager/ <%=rsArticleList( "pro_pic ")%> " border=0 width=123 height=123> </a> </td>
</tr>
</table>
</div> </td>
</tr>
<tr>
<td height= "20 "> <div align= "center " class= "ziti "> <%=gotTopic(rsArticleList( "pro_name "),15)%> </div> </td>


</tr>
<tr>
<td height= "20 "> 市场价: <%=rsArticleList( "pro_markprice ")%> 元 </td>
</tr>
<tr>
<td height= "20 "> 会员价: <span class= "style28 "> <%=rsArticleList( "pro_userprice ")%> </span> 元 </td>
</tr>
</table> </td>
<%
if n mod 5=0 then response.write " </TR> "
num = num +1
rsArticleList.movenext
loop
%>


自己把代码拷到dw下调试~

热点排行