总是有这样的错误提示啊!!!
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.   

    我把public partial class index 改成了public partial class pagination这回倒是编译成功了。可是页面上并不显示数据啊。我已经在数据库里添加了内容了啊
      

  2.   

    public partial class index中,index这个类是不是和.aspx页面的inherits=""的类匹配啊?
      

  3.   

    命名有冲突?
    页面上不显示数据?
    检查SQL,断点跟踪
      

  4.   


    我把public partial class index 改成了public partial class pagination这回倒是编译成功了。可是页面上并不显示数据啊。我已经在数据库里添加了内容了啊 
      

  5.   

    楼主要写的类貌似要实现IHttpHandler接口
      

  6.   

    //页面上的控件先注释
    //show.Text = html;
    //LblTitle.Text = "ASP.NET分页代码……共有" + Convert.ToInt32(Math.Ceiling(temp)) + "页/当前是第" + Page + "页";你要在页面上先添加对应的控件(应该是2个Label,"show" 和"LblTitle"),并把上面的注释去掉
      

  7.   

    上面的编译错误应该是页面上第一行的<%@ Page %>中Inherits的值跟.cs类型不匹配.
      

  8.   

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" %>
      

  9.   

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" %> 
    你看下你的页面Inherits里的类名和你.cs文件里的类名一样不?
      

  10.   

    页面上拖4个button. 分别对应.cs里的4个事件.
    如:
    protected void BtnFirst_Click(object sender, EventArgs e)加个button
    <asp:Button ID="B1" runat="server" Text="First" OnClick="BtnFirst" />