using System; 
using System.Data; 
using System.Configuration; 
using System.Collections; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
using Entity; 
using BLL; 
public partial class Manage_UpdateSwamiInfo : System.Web.UI.Page 

    SwamiEntity swamientity = new SwamiEntity(); 
    SwamiInfoBLL swamiinfobll = new SwamiInfoBLL(); 
    public static int CurrPage =1; 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!Page.IsPostBack) 
        { 
            this.SwamiInfoBind(); 
        }     } 
    public void SwamiInfoBind() 
    { 
        PagedDataSource page = new PagedDataSource(); 
        page.DataSource =swamiinfobll.SwamiInfo().DefaultView; 
        page.AllowPaging = true; 
        page.PageSize = 6; 
        page.CurrentPageIndex = CurrPage - 1; 
        if (page.IsFirstPage) 
        { 
            this.Button1.Enabled = false; 
        } 
        else 
        { 
            this.Button1.Enabled = true; 
        } 
        if (page.IsLastPage) 
        { 
            this.Button2.Enabled = false; 
        } 
        else 
        { 
            this.Button2.Enabled = true; 
        } 
        this.DataGrid1.DataSource = page; 
        this.DataGrid1.DataKeyField = "Sid"; 
        this.DataBind(); 
    } 
    protected string PartSubString(string s) 
    { 
        if (s.Length > 15) 
        { 
            return s.Substring(0, 15) + "..."; 
        } 
        return s; 
    } 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        CurrPage--; 
        this.SwamiInfoBind(); 
    } 
    protected void Button2_Click(object sender, EventArgs e) 
    { 
        CurrPage++; 
        this.SwamiInfoBind(); 
    } 

我用PagedDataSource实现分页功能,但是当到了最后一页或第一页,再刷新时,就报索引为负数了,就发生异常了,为什么刷新时PagedDataSource还在继续走啊!!如何能解决啊!!!