那位高手帮我修改一下ASP代码 分页中的问题,急!急!急! 5
我要每行4个图片,每页4行,再分页。但问题是,我修改了(每页记录条数)中的数值4,就会出现每行4个图片,但到第二行第5个图片时会分页了,还没到第四行16张图片就分页了。觉...
我要每行4个图片,每页4行,再分页。但问题是,我修改了(每页记录条数)中的数值4,就会出现每行4个图片,但到第二行第5个图片时会分页了,还没到第四行16张图片就分页了。觉得少了什么代码和哪里没修改对,请高手帮我看看以下代码。
set strs=server.createobject("adodb.recordset")
stsql="select * from pic order by id desc"
strs.open stsql, conn, 1, 1
if not strs.eof then
strs.PageSize =4 '每页记录条数
result_num=strs.RecordCount '记录总数
maxpage=strs.PageCount
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
strs.AbsolutePage=Page
else
result_num=0
maxpage=0
page=0
end if
if not strs.eof then
for i=1 to strs.PageSize
%>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=200 height=136><div align="center">
<%if not strs.eof then %>
<a href="pic_info.asp?id=<%=strs("id")%>" title="<%=strs("name")%>"><img src="admin/<%=strs("pic_slt")%>" width="160" height="120" border="0" /></a>
<% end if %>
</div></td>
<% strs.movenext %>
<td width=200 height=136><div align="center">
<%if not strs.eof then %>
<a href="pic_info.asp?id=<%=strs("id")%>" title="<%=strs("name")%>"><img src="admin/<%=strs("pic_slt")%>" width="160" height="120" border="0" /></a>
<% end if %>
</div></td>
<% strs.movenext %>
<td width=200 height=136><div align="center">
<%if not strs.eof then %>
<a href="pic_info.asp?id=<%=strs("id")%>" title="<%=strs("name")%>"><img src="admin/<%=strs("pic_slt")%>" width="160" height="120" border="0" /></a>
<% end if %>
</div></td>
<% strs.movenext %>
<td width=200 height=136><div align="center">
<%if not strs.eof then %>
<a href="pic_info.asp?id=<%=strs("id")%>" title="<%=strs("name")%>"><img src="admin/<%=strs("pic_slt")%>" width="160" height="120" border="0" /></a>
<% end if %>
</div></td>
</tr>
</table>
<%
strs.movenext
if strs.EOF then Exit For
next
end if
strs.close
set strs=nothing
%></td> 展开
set strs=server.createobject("adodb.recordset")
stsql="select * from pic order by id desc"
strs.open stsql, conn, 1, 1
if not strs.eof then
strs.PageSize =4 '每页记录条数
result_num=strs.RecordCount '记录总数
maxpage=strs.PageCount
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
strs.AbsolutePage=Page
else
result_num=0
maxpage=0
page=0
end if
if not strs.eof then
for i=1 to strs.PageSize
%>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=200 height=136><div align="center">
<%if not strs.eof then %>
<a href="pic_info.asp?id=<%=strs("id")%>" title="<%=strs("name")%>"><img src="admin/<%=strs("pic_slt")%>" width="160" height="120" border="0" /></a>
<% end if %>
</div></td>
<% strs.movenext %>
<td width=200 height=136><div align="center">
<%if not strs.eof then %>
<a href="pic_info.asp?id=<%=strs("id")%>" title="<%=strs("name")%>"><img src="admin/<%=strs("pic_slt")%>" width="160" height="120" border="0" /></a>
<% end if %>
</div></td>
<% strs.movenext %>
<td width=200 height=136><div align="center">
<%if not strs.eof then %>
<a href="pic_info.asp?id=<%=strs("id")%>" title="<%=strs("name")%>"><img src="admin/<%=strs("pic_slt")%>" width="160" height="120" border="0" /></a>
<% end if %>
</div></td>
<% strs.movenext %>
<td width=200 height=136><div align="center">
<%if not strs.eof then %>
<a href="pic_info.asp?id=<%=strs("id")%>" title="<%=strs("name")%>"><img src="admin/<%=strs("pic_slt")%>" width="160" height="120" border="0" /></a>
<% end if %>
</div></td>
</tr>
</table>
<%
strs.movenext
if strs.EOF then Exit For
next
end if
strs.close
set strs=nothing
%></td> 展开
3个回答
展开全部
只有5分 真可怜
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<%
set strs=server.createobject("adodb.recordset")
stsql="select * from pic order by id desc"
strs.open stsql, conn, 1, 1
if not strs.eof then
strs.PageSize =16 '每页记录条数
result_num=strs.RecordCount '记录总数
maxpage=strs.PageCount
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
strs.AbsolutePage=Page
else
result_num=0
maxpage=0
page=0
end if
if not strs.eof then
j=1
for i=1 to strs.PageSize
%>
<td width=200 height=136><div align="center">
<%if not strs.eof then %>
<a href="pic_info.asp?id=<%=strs("id")%>" title="<%=strs("name")%>"><img src="admin/<%=strs("pic_slt")%>" width="160" height="120" border="0" /></a>
<% end if %>
</div></td>
<%
if j mod 4 =0 then response.write "</tr></table><table width=100% border=0 cellspacing=0 cellpadding=0><tr>"
j=j+1
strs.movenext
if strs.EOF then Exit For
next
end if
strs.close
set strs=nothing
%>
</tr>
</table>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<%
set strs=server.createobject("adodb.recordset")
stsql="select * from pic order by id desc"
strs.open stsql, conn, 1, 1
if not strs.eof then
strs.PageSize =16 '每页记录条数
result_num=strs.RecordCount '记录总数
maxpage=strs.PageCount
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
strs.AbsolutePage=Page
else
result_num=0
maxpage=0
page=0
end if
if not strs.eof then
j=1
for i=1 to strs.PageSize
%>
<td width=200 height=136><div align="center">
<%if not strs.eof then %>
<a href="pic_info.asp?id=<%=strs("id")%>" title="<%=strs("name")%>"><img src="admin/<%=strs("pic_slt")%>" width="160" height="120" border="0" /></a>
<% end if %>
</div></td>
<%
if j mod 4 =0 then response.write "</tr></table><table width=100% border=0 cellspacing=0 cellpadding=0><tr>"
j=j+1
strs.movenext
if strs.EOF then Exit For
next
end if
strs.close
set strs=nothing
%>
</tr>
</table>
展开全部
html 里加个
<%@ Register Assembly="Tools" Namespace="Tools" TagPrefix="cc1" %>加在page后面
这个加在<body>里面前行了
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td style="height: 19px">
<cc1:listpage id="ListPage1" runat="server" />
</td>
</tr>
</table>
private int i = 1;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
fill();
}
}
private void fill()
{
int pageindex = HouseFcClassLibrary.db.getpage("page");
int _count = db.tongji("select count(*) from kh_loupan");
int pagesize = 10;
int pagecount = Convert.ToInt32(Math.Ceiling(_count / (pagesize + 0.00)));
if (pageindex > pagecount)
{
pageindex = pagecount;
}
int MAX = (pageindex - 1) * pagesize + 1;
string sqlwhere = "select top " + pagesize + " intid,[name],[content],[pic] from kh_loupan where (intid<=(select min(intid) from ( select top " + MAX + " intid from kh_loupan order by intid desc)as t )) order by intid desc";
db.bindrepeater(Repeater1, sqlwhere);
ListPage1.Allcount = _count;
ListPage1.Pageindex = pageindex;
ListPage1.Pagesize = pagesize;
ListPage1.UrlString = "lpzs-$p$.aspx";
}
protected string Cutstring(string str, int start, int lenngth)
{
byte[] bytes = System.Text.Encoding.Unicode.GetBytes(str);
lenngth = lenngth / 2 * 2;
if (bytes.Length > lenngth)
{
str = System.Text.Encoding.Unicode.GetString(bytes, start, lenngth) + "...";
}
return str;
}
protected string ParseTags(string HTML)
{
return System.Text.RegularExpressions.Regex.Replace(HTML, "<[^>]*>", "");
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (i % 2 == 0)
{ //这里的3就代表表格有3列
e.Item.Controls.Add(new LiteralControl("</tr><tr>"));
}
i++;
}
<%@ Register Assembly="Tools" Namespace="Tools" TagPrefix="cc1" %>加在page后面
这个加在<body>里面前行了
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td style="height: 19px">
<cc1:listpage id="ListPage1" runat="server" />
</td>
</tr>
</table>
private int i = 1;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
fill();
}
}
private void fill()
{
int pageindex = HouseFcClassLibrary.db.getpage("page");
int _count = db.tongji("select count(*) from kh_loupan");
int pagesize = 10;
int pagecount = Convert.ToInt32(Math.Ceiling(_count / (pagesize + 0.00)));
if (pageindex > pagecount)
{
pageindex = pagecount;
}
int MAX = (pageindex - 1) * pagesize + 1;
string sqlwhere = "select top " + pagesize + " intid,[name],[content],[pic] from kh_loupan where (intid<=(select min(intid) from ( select top " + MAX + " intid from kh_loupan order by intid desc)as t )) order by intid desc";
db.bindrepeater(Repeater1, sqlwhere);
ListPage1.Allcount = _count;
ListPage1.Pageindex = pageindex;
ListPage1.Pagesize = pagesize;
ListPage1.UrlString = "lpzs-$p$.aspx";
}
protected string Cutstring(string str, int start, int lenngth)
{
byte[] bytes = System.Text.Encoding.Unicode.GetBytes(str);
lenngth = lenngth / 2 * 2;
if (bytes.Length > lenngth)
{
str = System.Text.Encoding.Unicode.GetString(bytes, start, lenngth) + "...";
}
return str;
}
protected string ParseTags(string HTML)
{
return System.Text.RegularExpressions.Regex.Replace(HTML, "<[^>]*>", "");
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (i % 2 == 0)
{ //这里的3就代表表格有3列
e.Item.Controls.Add(new LiteralControl("</tr><tr>"));
}
i++;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你把这里改成strs.PageSize =16不就可以了吗,这样就是每页16张图片了
参考资料: 如果您的回答是从其他地方引用,请表明出处
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询