After checking the information on the Internet, there are too many methods for this DataGrid paging. Some solutions are too tricky, and some are less efficient. Here is a method that is not too troublesome and is reasonably efficient (caching the DataSet through the Session):
Drag Move the DataGrid to WebForms, select Columns from the DataGrid's property bar to open the DataGrid Properties custom dialog box, select Paging, Allow paging, Page size: 20.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!this.IsPostBack)
{
sqlDataAdapter1.Fill(dataSet11);
Session["CopyYear"]=dataSet11;
DataGrid1.DataSource = dataSet11.Tables[0].DefaultView;
DataGrid1.DataBind();
}
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex=e.NewPageIndex;
dataSet11=(DataSet1)Session["CopyYear"];
DataGrid1.DataSource = dataSet11.Tables[0].DefaultView;
DataGrid1.DataBind();
}
Add the above code to the page, OK
http://www.cnblogs.com/ericguo/archive/2006/11/21/practice_datagrid_page.html