页面索引不起作用

时间:2008-09-17 22:13:04

标签: c#

帮助我..我的页面索引在visual studio中不起作用。 我的页面加载如下:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CustomerView.DataSource = Customer.GetAll();
                CustomerView.DataBind();
            }
        }

protected void CustomerView_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
        {
            int newPageNumber = e.NewPageIndex + 1;
            CustomerView.DataSource = Customer.GetAll();
            CustomerView.DataBind();
        }

我做错了我的页面索引无法正常工作。

1 个答案:

答案 0 :(得分:0)

试试这个。我认为你必须手动设置GridView的PageIndex属性。

protected void CustomerView_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
{
    CustomerView.PageIndex = e.NewPageIndex;
    CustomerView.DataSource = Customer.GetAll();
    CustomerView.DataBind();
}