总是有这样的错误提示啊!!!
1。“ASP.index_aspx.GetTypeHashCode()”: 没有找到适合的方法来重写 2。“ASP.index_aspx.ProcessRequest(System.Web.HttpContext)”: 没有找到适合的方法来重写 3.“ASP.index_aspx”不会实现接口成员“System.Web.IHttpHandler.IsReusable”
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
public partial class index : System.Web.UI.Page
{
public int PageSize = 10; //设置每页显示多少条记录
protected void Page_Load(object sender, EventArgs e)
{
//建立连接
//SqlConnection conn = DB.Connection();
SqlConnection conn = new SqlConnection("server=WANXU;database=page;uid=sa;pwd=999999");
conn.Open();
//查看是否已经连接上 Response.Write(conn.State.ToString());
string strSQL = "select count(*) from pagination ";
SqlCommand cmd = new SqlCommand(strSQL, conn);
int MaxSize = Convert.ToInt32(cmd.ExecuteScalar()); //取出总笔数
int Page = Convert.ToInt32(Request.QueryString.Get("PageID")); //获取页码
if (Page == 0)
{
Page = 1;
}
float temp = (float)MaxSize / PageSize;
if (Page >= Convert.ToInt32(Math.Ceiling(temp)))
{
Page = Convert.ToInt32(Math.Ceiling(temp));
}
string SQL = "select top " + PageSize + " * from pagination where UserID>" + (Page - 1) * PageSize;
SqlCommand scmd = new SqlCommand(SQL, conn);
SqlDataReader sdr = scmd.ExecuteReader();
string html = "<table border=1>";
html += "<tr>";
html += "<td width=150px>用 户 名</td>";
html += "<td width=100px>密 码</td>";
html += "<td width=250px>地 址</td>";
html += "</tr>";
while (sdr.Read())
{
html += "<tr>";
html += "<td width=150px>" + sdr["UserName"].ToString() + "</td>";
html += "<td width=100px>" + sdr["UserPwd"].ToString() + "</td>";
html += "<td width=250px>" + sdr["UserAddr"].ToString() + "</td>";
html += "</tr>";
}
html += "</table>"; //关闭连接
sdr.Close();
conn.Close(); //页面上的控件先注释
//show.Text = html;
//LblTitle.Text = "ASP.NET分页代码……共有" + Convert.ToInt32(Math.Ceiling(temp)) + "页/当前是第" + Page + "页"; }
protected void BtnFirst_Click(object sender, EventArgs e)
{
Response.Redirect("pagination.aspx?PageID=1");
}
protected void BtnPre_Click(object sender, EventArgs e)
{
int Page = Convert.ToInt32(Request.QueryString.Get("PageID"));
if (Page <= 1)
{
Page = 2;
}
int curent = Page - 1;
Response.Redirect("pagination.aspx?PageID=" + curent);
}
protected void BtnNext_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=WANXU;database=page;uid=sa;pwd=999999");
conn.Open(); string strSQL = "select count(*) from pagination ";
SqlCommand cmd = new SqlCommand(strSQL, conn);
int MaxSize = Convert.ToInt32(cmd.ExecuteScalar()); //取出总笔数
int Page = Convert.ToInt32(Request.QueryString.Get("PageID"));
float temp = (float)MaxSize / PageSize;
if (Page >= Convert.ToInt32(Math.Ceiling(temp)))
{
Page = Convert.ToInt32(Math.Ceiling(temp)) - 1;
}
if (Page <= 0)
{
Page = 1;
}
int curent = Page + 1;
Response.Redirect("pagination.aspx?PageID=" + curent);
conn.Close();
}
protected void BtnLast_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=WANXU;database=page;uid=sa;pwd=999999");
conn.Open();
string strSQL = "select count(*) from pagination ";
SqlCommand cmd = new SqlCommand(strSQL, conn);
int MaxSize = Convert.ToInt32(cmd.ExecuteScalar()); //取出总笔数
float temp = (float)MaxSize / PageSize;
Response.Redirect("pagination.aspx?PageID=" + Math.Ceiling(temp));
conn.Close();
}
}
1。“ASP.index_aspx.GetTypeHashCode()”: 没有找到适合的方法来重写 2。“ASP.index_aspx.ProcessRequest(System.Web.HttpContext)”: 没有找到适合的方法来重写 3.“ASP.index_aspx”不会实现接口成员“System.Web.IHttpHandler.IsReusable”
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
public partial class index : System.Web.UI.Page
{
public int PageSize = 10; //设置每页显示多少条记录
protected void Page_Load(object sender, EventArgs e)
{
//建立连接
//SqlConnection conn = DB.Connection();
SqlConnection conn = new SqlConnection("server=WANXU;database=page;uid=sa;pwd=999999");
conn.Open();
//查看是否已经连接上 Response.Write(conn.State.ToString());
string strSQL = "select count(*) from pagination ";
SqlCommand cmd = new SqlCommand(strSQL, conn);
int MaxSize = Convert.ToInt32(cmd.ExecuteScalar()); //取出总笔数
int Page = Convert.ToInt32(Request.QueryString.Get("PageID")); //获取页码
if (Page == 0)
{
Page = 1;
}
float temp = (float)MaxSize / PageSize;
if (Page >= Convert.ToInt32(Math.Ceiling(temp)))
{
Page = Convert.ToInt32(Math.Ceiling(temp));
}
string SQL = "select top " + PageSize + " * from pagination where UserID>" + (Page - 1) * PageSize;
SqlCommand scmd = new SqlCommand(SQL, conn);
SqlDataReader sdr = scmd.ExecuteReader();
string html = "<table border=1>";
html += "<tr>";
html += "<td width=150px>用 户 名</td>";
html += "<td width=100px>密 码</td>";
html += "<td width=250px>地 址</td>";
html += "</tr>";
while (sdr.Read())
{
html += "<tr>";
html += "<td width=150px>" + sdr["UserName"].ToString() + "</td>";
html += "<td width=100px>" + sdr["UserPwd"].ToString() + "</td>";
html += "<td width=250px>" + sdr["UserAddr"].ToString() + "</td>";
html += "</tr>";
}
html += "</table>"; //关闭连接
sdr.Close();
conn.Close(); //页面上的控件先注释
//show.Text = html;
//LblTitle.Text = "ASP.NET分页代码……共有" + Convert.ToInt32(Math.Ceiling(temp)) + "页/当前是第" + Page + "页"; }
protected void BtnFirst_Click(object sender, EventArgs e)
{
Response.Redirect("pagination.aspx?PageID=1");
}
protected void BtnPre_Click(object sender, EventArgs e)
{
int Page = Convert.ToInt32(Request.QueryString.Get("PageID"));
if (Page <= 1)
{
Page = 2;
}
int curent = Page - 1;
Response.Redirect("pagination.aspx?PageID=" + curent);
}
protected void BtnNext_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=WANXU;database=page;uid=sa;pwd=999999");
conn.Open(); string strSQL = "select count(*) from pagination ";
SqlCommand cmd = new SqlCommand(strSQL, conn);
int MaxSize = Convert.ToInt32(cmd.ExecuteScalar()); //取出总笔数
int Page = Convert.ToInt32(Request.QueryString.Get("PageID"));
float temp = (float)MaxSize / PageSize;
if (Page >= Convert.ToInt32(Math.Ceiling(temp)))
{
Page = Convert.ToInt32(Math.Ceiling(temp)) - 1;
}
if (Page <= 0)
{
Page = 1;
}
int curent = Page + 1;
Response.Redirect("pagination.aspx?PageID=" + curent);
conn.Close();
}
protected void BtnLast_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=WANXU;database=page;uid=sa;pwd=999999");
conn.Open();
string strSQL = "select count(*) from pagination ";
SqlCommand cmd = new SqlCommand(strSQL, conn);
int MaxSize = Convert.ToInt32(cmd.ExecuteScalar()); //取出总笔数
float temp = (float)MaxSize / PageSize;
Response.Redirect("pagination.aspx?PageID=" + Math.Ceiling(temp));
conn.Close();
}
}
解决方案 »
- 调试.net程序时,出现无法找到internet
- 问个关于csdn回复帖子实现的问题
- 关于引入dataset时的一个错误
- 图片 文档上传数据库,在线修改、保存到数据库
- 请问DataGrid 中的 onupdatacommand 事件代码应该如何写
- 用SqlCconnection连接本地数据库,它的ConnectionString该怎么写啊???
- 怎样打包asp.net 安装呀
- json前台传值到后台,后台获取问题 .net
- 求救:“未将对象引用设置到对象的实例”
- 如何使一个文本框的初始状态就是选中呢?
- Enterprise Library 中 Instrumentation的介绍哪里有?
- 快被炒啦,大家帮忙看一下这个简单的ASP功能啊,有分!
页面上不显示数据?
检查SQL,断点跟踪
我把public partial class index 改成了public partial class pagination这回倒是编译成功了。可是页面上并不显示数据啊。我已经在数据库里添加了内容了啊
//show.Text = html;
//LblTitle.Text = "ASP.NET分页代码……共有" + Convert.ToInt32(Math.Ceiling(temp)) + "页/当前是第" + Page + "页";你要在页面上先添加对应的控件(应该是2个Label,"show" 和"LblTitle"),并把上面的注释去掉
你看下你的页面Inherits里的类名和你.cs文件里的类名一样不?
如:
protected void BtnFirst_Click(object sender, EventArgs e)加个button
<asp:Button ID="B1" runat="server" Text="First" OnClick="BtnFirst" />