PageIndexChanging in GridView in ASP.NET

后端 未结 4 2097
我寻月下人不归
我寻月下人不归 2021-02-05 05:09

I have a gridview which I am using to display a dataset result. The problem is I am using paging in it. But when I click on the page # it says that I haven\'t handled the event.

4条回答
  •  遥遥无期
    2021-02-05 05:57

    You should set the .PageIndex before binding data! Otherwise, you would need extra clicks which actually double the BindData method calls. The following is my tested vb code.

    Private Sub GridViewL_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridViewL.PageIndexChanging
    
        GridViewL.PageIndex = e.NewPageIndex
        BindData()  ' your method to bind data to the grid
    End Sub
    

提交回复
热议问题