asp.net|datagrid| Paging
Check online data, about this DataGrid paging is too many methods, some solutions are too trick, some are inefficient, here provides a less cumbersome, but also efficient (through the session cache DataSet) method:
Drag the DataGrid to WebForms, select columns from the DataGrid's property bar to open the DataGrid Properties Customization dialog box, select paging pagination, 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 on the page, OK