【问题标题】:Gridview Pagination errorGridview分页错误
【发布时间】:2011-02-11 10:11:09
【问题描述】:

我正在尝试在我的 gridview 控件中实现分页。这是databind和pageindexchanged的代码

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() as 之后出现错误

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

为什么会出现这个错误?有什么帮助吗?

【问题讨论】:

    标签: asp.net vb.net gridview pagination


    【解决方案1】:

    这不会有任何区别,因为事件处理程序的名称(在本例中为 PageIndexChanging)可以是任何名称,因为它也在 aspx 文件中定义。但是我的问题得到了解决,因为我从 aspx 触发了 OnPageIndexChanging 并在 OnPageIndexChanged 中处理它。改正它,它就起作用了。

    【讨论】:

      猜你喜欢
      • 2013-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-23
      相关资源
      最近更新 更多