直接贴代码。 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataGridBind(); } } /// <summary> /// 获取数据 /// </summary> private void DataGridBind() { text_actor myText = new text_actor(); DataSet ds = myText.GetList(""); AspNetPager1.RecordCount = ds.Tables[0].Rows.Count; PagedDataSource pds = new PagedDataSource(); pds.DataSource = ds.Tables[0].DefaultView; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; pds.AllowPaging = true; //AspNetPager1.CustomInfoHTML = "共%RecordCount%条数据 每页%PageSize%条 共%PageCount%页 当前第%CurrentPageIndex%页"; DataGrid1.DataSource = pds; DataGrid1.DataBind(); } protected void AspNetPager1_PageChanged(object sender, EventArgs e) { DataGridBind(); }