2011-02-11 91 views
0

我想在我的gridview控件中實現分頁。下面是數據綁定代碼和pageindexchangedGridview分頁錯誤

Private Sub BindGrid() 
    Dim dataTable as DataTable = CType(Session.Item(APPLICATION_DATA), DataTable) 
    Grid.DataSource = dataTable.DefaultView 
    Grid.DataBind() 
End Sub 

Protected Sub OnChangePageSize(ByVal send As Object, ByVal e As GridViewPageEventArgs) Handles Grid.PageIndexChanging 
    Grid.PageIndex = e.NewPageIndex 
    _BindGrid() 
End Sub 

,但我得到的錯誤Grid.DataBind(後)爲

"Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.GridViewPageEventArgs'" 

爲什麼這個錯誤?任何幫助?

回答

0

這不會有任何區別,因爲事件處理程序的名稱(本例中爲PageIndexChanging)可以是任何東西,因爲它也是在aspx文件中定義的。然而,我的問題已解決,因爲我從aspx激發了OnPageIndexChanging並處理了OnPageIndexChanged。糾正這一點,它的工作。