为什么我的datagrid不能自定义分页
//html代码
<asp:datagrid id= "DataGrid2 " runat= "server " Width= "320px " AutoGenerateColumns= "False " ShowHeader= "False "
GridLines= "None " AllowCustomPaging= "True " PageSize= "2 " AllowPaging= "True " OnPageIndexChanged= "DataGrid2_Page "> //该事件好象一直没触发义
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<IMG src= "/liu/images/arrow.gif ">
</ItemTemplate>
</asp:TemplateColumn>
<asp:HyperLinkColumn Target= "_parent " DataNavigateUrlField= "pid " DataNavigateUrlFormatString= "pshowdetail.aspx?id={0} "
DataTextField= "ptitle "> </asp:HyperLinkColumn>
<asp:TemplateColumn>
<ItemTemplate>
[
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField= "ptime " DataFormatString= "{0:d} "> </asp:BoundColumn>
<asp:BoundColumn DataField= "phit "> </asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<font color= "#33ff00 "> 次 </font> ]
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle Mode= "NumericPages "> </PagerStyle>
</asp:datagrid>
//page_load()
if(!this.Page.IsPostBack)
{
this.toptitle.Text= " <div align=center> <b> 查询结果如下: </b> </div> ";
this.filldate(gj,lx);
this.DataGrid2.VirtualItemCount=((DataTable)this.Session[ "searchtable "]).Rows.Count;
this.Response.Write(this.DataGrid2.VirtualItemCount);
this.BindGrid();
}
//分页事件
protected void DataGrid2_Page(Object sender,DataGridPageChangedEventArgs e)
{
this.DataGrid2.CurrentPageIndex = e.NewPageIndex;
startIndex = this.DataGrid2.CurrentPageIndex * this.DataGrid2.PageSize;
BindGrid();
}
//绑定
private void BindGrid()
{
this.DataGrid2.DataSource = CreateDataSource();
this.DataGrid2.DataBind();
}
//设计器支持所需的方法
private void InitializeComponent()
{
this.DataGrid2.PageIndexChanged+=new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid2_Page);
this.Load += new System.EventHandler(this.Page_Load);
}
------解决方案--------------------不是OnPageIndexChanged事件是PageIndexChanging事件。
protected void grdVendors_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridView.PageIndex = e.NewPageIndex;
gridView.DataSource