当我尝试执行以下操作时:
lblTotal.text = gwGrid.rows.count()
我总是得到 50,这是我页面的大小。我怎样才能得到返回的所有记录的计数,而不仅仅是那一页上显示的那些?
我还在我的数据源上尝试了 Selected 事件:
Protected Sub ObjectDataSource1_Selected(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs)
If e.Exception Is Nothing AndAlso e.ReturnValue IsNot Nothing Then
Dim dt As DataTable = TryCast(e.ReturnValue, DataTable)
Dim totalRecordCount As Integer = dt.Rows.Count
End If
End Sub
但我收到以下错误:
你调用的对象是空的。在这一行:第 85 行: Dim totalRecordCount As Integer = dt.Rows.Count
更新:我想通了:
Protected Sub ObjectDataSource1_Selected(ByVal sender As Object, ByVal e As ObjectDataSourceStatusEventArgs)
If e.Exception Is Nothing Then
Dim dt As DataSet = DirectCast(e.ReturnValue, DataSet)
If dt IsNot Nothing Then
lblTotal.Text = dt.Tables(0).Rows.Count.ToString()
Else
lblTotal.Text = "0"
End If
End If
End Sub