哥哥姐姐们请帮忙 为什么我在点击每一页按钮时总是显示第一页 代码如下:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
SqlConnection con=new SqlConnection("server=localhost;" +"database=MyData;Trusted_Connection=Yes");
SqlDataAdapter myAdapter=new SqlDataAdapter("select*from Stat",con);
DataSet ds=new DataSet();
myAdapter.Fill(ds);
DataView source=new DataView(ds.Tables[0]);
DataGrid1.DataSource=source;
DataGrid1.AllowPaging = true;
DataGrid1.PagerStyle.Mode = PagerMode.NumericPages;
DataGrid1.PagerStyle.PageButtonCount = 5;
DataGrid1.PageSize = 5;
if (!Page.IsPostBack)
{
DataGrid1.DataBind();
}
}
private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataBind();
}