拖動DataGrid到WebForms,從DataGrid的屬性欄中選擇Columns打開DataGrid Properties自定義對話框,選擇Paging分頁,Allow paging, Page size: 20。
{
// 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();
}
}
{
DataGrid1.CurrentPageIndex
=e.NewPageIndex;
dataSet11
=(DataSet1)Session["CopyYear"];
DataGrid1.DataSource
= dataSet11.Tables[0].DefaultView;
DataGrid1.DataBind();
}
在頁面上添加上述代碼,OK