GridView 分页问题
我是将GridView帮定到自定义实体集合.代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
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 ISCAP.PrintReport.ReportModel;
public partial class _Default : System.Web.UI.Page
{
private List <Customer> customers;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
customers = Customer.GetAllCustomers();
gridViewCustomers.DataSource = Customer.GetAllCustomers();
gridViewCustomers.DataBind();
}
}
protected void gridViewCustomers_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
gridViewCustomers.PageIndex = e.NewSelectedIndex;
gridViewCustomers.DataBind();
}
}
运行时点击GridView页数,出现以下错误:
The GridView 'gridViewCustomers ' fired event PageIndexChanging which wasn 't handled.
请问这个问题可能出现的原因是什么?
[解决办法]
要用下面的这个事件
PageIndexChanging
中的e.NewPageIndex