0

我正在尝试从一页导航到另一页gridview。当我尝试出错时

Compiler Error Message: CS0123: No overload for 'GridView1_PageIndexChanging'  
matches delegate 'System.Web.UI.WebControls.GridViewSelectEventHandler'

我的 ASPX 页面:

<pagersettings mode="Numeric"  position="Bottom"  pagebuttoncount="10"/>

<pagerstyle backcolor="LightBlue" height="30px" verticalalign="Bottom"   horizontalalign="Center"/>

</asp:GridView>

我在 C# 中的代码:

 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
    }

请帮帮我。

4

1 回答 1

1

通常,在将数据绑定到分页事件之前,您必须将其绑定到数据源。

这是示例。我使用视图状态来存储我在页面加载事件中检索到的数据表值。希望这可以帮助

 private void gridview1_PageIndexChanging(object sender,System.Web.UI.WebControls.GridViewPageEventArgs e)        
 {
    gridview1.ShowFooter = false;
    gridview1.EditIndex = -1;
    gridview1.PageIndex = e.NewPageIndex;
        if (ViewState("VW_Data") != null) {
            dtData= new DataTable();
            dtData= (DataTable)ViewState("VW_Data");

            gridview1.DataSource = dtData;
            gridview1.PageSize = ddlRecordsPerPage.SelectedValue;
            gridview1.DataBind();
        } 
       else {
               GetData();
            }
  }
于 2013-07-24T10:04:52.073 回答