1protected void Page_Load(object sender, EventArgs e)
 2{
 3    GetData();//重新获取操作后的数据源
 4    
 5    if (!Page.IsPostBack)
 6    {
 7        BindGrid();//绑定GridView,为删除服务
 8    }

 9}
    
10
11private void BindGrid()
12{
13    GridView1.DataSource = this.DataSource;
14    GridView1.DataBind();
15
16    if (!Page.IsPostBack) Session.Remove("PageIndex");//清除PageIndex项
17    object oSession = Session["PageIndex"];
18    if (oSession != null)
19        GridView1.PageIndex = Convert.ToInt32(oSession);//设置当前页
20}

21    
22protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
23{
24    GridView1.PageIndex = e.NewPageIndex;
25    Session["PageIndex"= e.NewPageIndex;//保存当前页码
26    BindGrid();
27}
posted on 2007-08-22 21:56  记得忘记  阅读(355)  评论(0)    收藏  举报