asp 分页显示的问题
<%setrs=Server.CreateObject("ADODB.RecordSet")sql="select*fromnewswheretype="&request...
<%
set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from news where type="&request.QueryString("type")&" order by date desc"
rs.open sql,conn,1,1
if rs.eof or rs.bof then
%>
<TR>
<TD vAlign=top>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD align=middle width=25 height=24><IMG
src="news.files/middle_icon.gif"></TD>
<TD style="FONT-SIZE: 13px"><SPAN id=lan1>暂无</SPAN></TD>
<TD style="FONT-SIZE: 13px" width=50>暂无</TD>
</TR>
<TR>
<TD align=right background=news.files/dotted_pic.gif
colSpan=3 height=1></TD></TR>
</TBODY></TABLE></TD></TR>
<%
else
rs.pagesize=4
currentpage=Clng(request("page"))
if currentpage<1 then currentpage=1
if currentpage>rs.pagecount then currentpage=rs.pagecount
rs.absolutepage=currentpage
Do While Not rs.Eof
%>
<TR>
<TD vAlign=top>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD align=middle width=25 height=24><IMG
src="news.files/middle_icon.gif"></TD>
<TD style="FONT-SIZE: 13px"><SPAN id=lan1><A id=ci149501
title=<%=rs("title")%>
href="news_info.asp?id=<%=rs("id")%>"
target=_blank><%=rs("title")%></A></SPAN></TD>
<TD style="FONT-SIZE: 13px" width=50><%=rs("date")%></TD></TR>
<TR>
<TD align=right background=news.files/dotted_pic.gif
colSpan=3 height=1></TD></TR>
</TBODY></TABLE></TD></TR>
<%
i=i+1
rs.MoveNext
If i>=rs.pagesize Then Exit Do
Loop
end if
%>
错误类型:
ADODB.Field (0x80020009)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
/yisu/newsinfo.asp
请问哪个地方出错了??? 展开
set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from news where type="&request.QueryString("type")&" order by date desc"
rs.open sql,conn,1,1
if rs.eof or rs.bof then
%>
<TR>
<TD vAlign=top>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD align=middle width=25 height=24><IMG
src="news.files/middle_icon.gif"></TD>
<TD style="FONT-SIZE: 13px"><SPAN id=lan1>暂无</SPAN></TD>
<TD style="FONT-SIZE: 13px" width=50>暂无</TD>
</TR>
<TR>
<TD align=right background=news.files/dotted_pic.gif
colSpan=3 height=1></TD></TR>
</TBODY></TABLE></TD></TR>
<%
else
rs.pagesize=4
currentpage=Clng(request("page"))
if currentpage<1 then currentpage=1
if currentpage>rs.pagecount then currentpage=rs.pagecount
rs.absolutepage=currentpage
Do While Not rs.Eof
%>
<TR>
<TD vAlign=top>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD align=middle width=25 height=24><IMG
src="news.files/middle_icon.gif"></TD>
<TD style="FONT-SIZE: 13px"><SPAN id=lan1><A id=ci149501
title=<%=rs("title")%>
href="news_info.asp?id=<%=rs("id")%>"
target=_blank><%=rs("title")%></A></SPAN></TD>
<TD style="FONT-SIZE: 13px" width=50><%=rs("date")%></TD></TR>
<TR>
<TD align=right background=news.files/dotted_pic.gif
colSpan=3 height=1></TD></TR>
</TBODY></TABLE></TD></TR>
<%
i=i+1
rs.MoveNext
If i>=rs.pagesize Then Exit Do
Loop
end if
%>
错误类型:
ADODB.Field (0x80020009)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
/yisu/newsinfo.asp
请问哪个地方出错了??? 展开
2个回答
2010-12-17
展开全部
把我的给你参考一下下吧,希望对你有帮助
/// <summary>
/// 分页 -- 页码改变
/// </summary>
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
if (e.NewPageIndex < 0) this.GridView1.PageIndex = 0;
else
this.GridView1.PageIndex = e.NewPageIndex;
DBind();
}
/// <summary>
/// 包含分页的处理
/// </summary>
protected void GridView1_DataBound(object sender, EventArgs e)
{
//处理分页部分
if (GridView1.PageCount > 1)
{
//首页
LinkButton p1 = (LinkButton)GridView1.BottomPagerRow.FindControl("page1");
//上一页
LinkButton p2 = (LinkButton)GridView1.BottomPagerRow.FindControl("page2");
//下一页
LinkButton p3 = (LinkButton)GridView1.BottomPagerRow.FindControl("page3");
//末页
LinkButton p4 = (LinkButton)GridView1.BottomPagerRow.FindControl("page4");
//第 页
Label l5 = (Label)GridView1.BottomPagerRow.FindControl("page5");
//共 页
Label l6 = (Label)GridView1.BottomPagerRow.FindControl("page6");
l5.Text = (GridView1.PageIndex + 1).ToString();
l6.Text = GridView1.PageCount.ToString();
if (GridView1.PageIndex == 0)
{
p1.Visible = false;
p2.Visible = false;
}
else
{
p1.Visible = true;
p2.Visible = true;
}
if (GridView1.PageIndex == GridView1.PageCount - 1)
{
p3.Visible = false;
p4.Visible = false;
}
else
{
p3.Visible = true;
p4.Visible = true;
}
}
//分页处理部分结束
}
/// <summary>
/// 跳转
/// </summary>
protected void page8_Click(object sender, EventArgs e)
{
TextBox t7 = (TextBox)GridView1.BottomPagerRow.FindControl("page7");
int p = 0;
try
{
p = int.Parse(t7.Text.ToString());
if (p > 0 && p <= GridView1.PageCount)
{
GridView1.PageIndex = p - 1;
}
}
catch
{
}
}
/// <summary>
/// 页长
/// </summary>
protected void page11_Click(object sender, EventArgs e)
{
TextBox t10 = (TextBox)GridView1.BottomPagerRow.FindControl("page10");
int z = 0;
try
{
z = int.Parse(t10.Text.ToString());
if (z > 0)
{
GridView1.PageSize = z;
}
}
catch
{
}
DBind();
}
/// <summary>
/// 分页 -- 页码改变
/// </summary>
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
if (e.NewPageIndex < 0) this.GridView1.PageIndex = 0;
else
this.GridView1.PageIndex = e.NewPageIndex;
DBind();
}
/// <summary>
/// 包含分页的处理
/// </summary>
protected void GridView1_DataBound(object sender, EventArgs e)
{
//处理分页部分
if (GridView1.PageCount > 1)
{
//首页
LinkButton p1 = (LinkButton)GridView1.BottomPagerRow.FindControl("page1");
//上一页
LinkButton p2 = (LinkButton)GridView1.BottomPagerRow.FindControl("page2");
//下一页
LinkButton p3 = (LinkButton)GridView1.BottomPagerRow.FindControl("page3");
//末页
LinkButton p4 = (LinkButton)GridView1.BottomPagerRow.FindControl("page4");
//第 页
Label l5 = (Label)GridView1.BottomPagerRow.FindControl("page5");
//共 页
Label l6 = (Label)GridView1.BottomPagerRow.FindControl("page6");
l5.Text = (GridView1.PageIndex + 1).ToString();
l6.Text = GridView1.PageCount.ToString();
if (GridView1.PageIndex == 0)
{
p1.Visible = false;
p2.Visible = false;
}
else
{
p1.Visible = true;
p2.Visible = true;
}
if (GridView1.PageIndex == GridView1.PageCount - 1)
{
p3.Visible = false;
p4.Visible = false;
}
else
{
p3.Visible = true;
p4.Visible = true;
}
}
//分页处理部分结束
}
/// <summary>
/// 跳转
/// </summary>
protected void page8_Click(object sender, EventArgs e)
{
TextBox t7 = (TextBox)GridView1.BottomPagerRow.FindControl("page7");
int p = 0;
try
{
p = int.Parse(t7.Text.ToString());
if (p > 0 && p <= GridView1.PageCount)
{
GridView1.PageIndex = p - 1;
}
}
catch
{
}
}
/// <summary>
/// 页长
/// </summary>
protected void page11_Click(object sender, EventArgs e)
{
TextBox t10 = (TextBox)GridView1.BottomPagerRow.FindControl("page10");
int z = 0;
try
{
z = int.Parse(t10.Text.ToString());
if (z > 0)
{
GridView1.PageSize = z;
}
}
catch
{
}
DBind();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询