由于 我不会用这个控件  所有上网查了 下 找到 
如下 代码public partial class _Default : System.Web.UI.Page 
{    protected OleDbConnection conn = new OleDbConnection();
    protected OleDbCommand cmd = new OleDbCommand();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            initdb();
            conn.Open();
            cmd.CommandText = "select count(*) from t_product";
            AspNetPager1.RecordCount = (int)cmd.ExecuteScalar();
            conn.Close();
            BindData();
        }    }
    protected void BindData()
    {
        initdb();
        OleDbDataAdapter sda = new OleDbDataAdapter("select * from t_product", conn);
        DataSet ds = new DataSet();
        //sda.Fill(ds, 10, 10, "temptbl");
        sda.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "temptbl");
        DataList1.DataSource = ds.Tables["temptbl"];
        DataList1.DataBind();
    }    protected void initdb()
    {
        conn.ConnectionString = oledbtool.myConnStr + Server.MapPath(oledbtool.mydbName);
        cmd.Connection = conn;
    }    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = e.NewPageIndex;
        BindData();
    }
}
但为何 报这样的错错误 4 “System.EventArgs”不包含“NewPageIndex”的定义,并且找不到可接受类型为“System.EventArgs”的第一个参数的扩展方法“NewPageIndex”(是否缺少 using 指令或程序集引用?)这句 要添加什么引用吗 ??AspNetPager1.CurrentPageIndex = e.NewPageIndex;
我看了类似的 都写这样的 代码 但为什么我会报错 
不解

解决方案 »

  1.   

    我自己解决了   在问个问题
    AspNetPager1 能用Ajax吗
      

  2.   

    直接托到updatepannel看看,可以的话应该就可以。
      

  3.   

    可以用的。
    参考:http://www.ej38.com/askshow/ajax-127648.html
      

  4.   

    新版的AspnetPager不用设了  protected void AspNetPager1_PageChanged(object sender, EventArgs e)
      {
      //AspNetPager1.CurrentPageIndex = e.NewPageIndex;
      BindData();
      }
      

  5.   

    MVC版本的支持AJAX分页
    asp.net版本的好像没有
      

  6.   

    da.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1),AspNetPager1.PageSize, "table1");// 翻页事件
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bind(); // 直接绑定数据即可      
    }