他写的示例初学者根本不会用的,我也是费了好大劲才弄会的,不过不是用存储过程,给你看看: public void BindData()
    {
        string connstr = System.Configuration.ConfigurationManager.AppSettings["SqlConnectionString"];        SqlConnection myConn = new SqlConnection(connstr);
        myConn.Open();        string sql = "select * from TestPager"; //告诉程序要读取哪张表的数据
        SqlDataAdapter myAdapter = new SqlDataAdapter(sql, myConn);
        DataSet ds = new DataSet();
        myAdapter.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "dtable");
        myConn.Close();                this.Repeater1.DataSource = ds.Tables[0].DefaultView;
        this.Repeater1.DataBind();
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindData();    }

解决方案 »

  1.   

    SqlConnection conn = new SqlConnection("server=localhost;database=bgglxt;uid=sa;pwd='7802456'");
                   conn.Open();
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.CommandText = "SELECT  * FROM basic_plan";
                    cmd.Connection = conn;
                    SqlDataAdapter da = new SqlDataAdapter();
                    da.SelectCommand = cmd;
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                   PagedDataSource objPage = new PagedDataSource();
                    objPage.DataSource = ds.Tables[0].DefaultView;
                    objPage.AllowPaging = true;
                    objPage.PageSize = 20;
                    int CurPage;
                    if (Request.QueryString["Page"] != null)
                        CurPage = Convert.ToInt32(Request.QueryString["Page"]);
                    else CurPage = 1;
                    objPage.CurrentPageIndex = CurPage - 1;
                    lblCurPage.Text = "总" + objPage.PageCount.ToString() + "页 当前第" + CurPage.ToString() + "页";
                    HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?&Page=" + objPage.PageCount;
                    HyperLink2.NavigateUrl = Request.CurrentExecutionFilePath;
                    Labely.Text = CurPage.ToString();
                    if (!objPage.IsFirstPage)
                    {
                        LnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?&Page=" + Convert.ToString(CurPage - 1);
                                        }
                    if (!objPage.IsLastPage)
                    {
                        LnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?&Page=" + Convert.ToString(CurPage + 1);
                                        }                Repeater1.DataSource = objPage;
                    Repeater1.DataBind();
                    da.Dispose();
                    conn.Close();
      

  2.   

    http://www.webdiyer.com/ 有例子下载。
      

  3.   

    还是没有搞懂
    我以我的程序说明DataGrid
    ----------------------------
    分页控件。。后台代码:
    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    if(!this.IsPostBack)
    {
    Showinfo();
    }
    }private void ShowNews()
    {                           
    DataSet ds=Tools.GetAll(......);//得到一个ds
    int pageCount=Tools.GetCount();//得到总记录数
    //我能给的参数就是这些
    this.dg_s.DataSource=ds.Tables[0].DefaultView;
    this.dg_s.DataBind();
    //后边的就不会了
    } private void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
    {
    //这里也不会

    }
      

  4.   

    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go
    ALTER proc [dbo].[EmpPage]
    @pagesize int,
    @currentpageIndex int
    as 
      declare @sql nvarchar(500)
      set @sql=' select Top '+ convert(varchar(10),@pagesize)+
               ' * from NewsInfo where NewsId not in (select Top '+
                 convert(varchar(10),(@currentpageIndex-1) * @pagesize)+
               ' NewsId from NewsInfo order by NewsId ASC) order by NewsId ASC '
    exec sp_executesql @sql