0

我想在 gridview 中找到总行数。这是我的代码,页面大小= 10

   Private Sub GridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles CustomGridView1.RowDataBound
    Dim Count As Integer = CustomGridView1.Rows.Count()
    If e.Row.RowType = DataControlRowType.Footer Then
        e.Row.Cells(5).Text = Count & " of " & getstudents.Count()
    End If
End Sub

页脚在第一页显示为 10 0f 50 但我想显示为 1-10 of 50 。在第二页中它显示相同,但​​我想显示为 11-20 of 50。谁能告诉我如何显示这样的页脚文本。

4

1 回答 1

4

是的,您必须声明一个变量来分配该函数的值。

Dim int as integer

int = CustomGridView1.Rows.Count()

.Count() 函数返回一个整数值。您必须将该整数值存储在某处,否则调用该函数毫无意义。

编辑 - - -

也许是这样的

Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(2).Text = (variable you defined above)
        End If
    End Sub           

这只是我最好的猜测。我通常不使用页脚。

于 2012-09-14T17:27:01.520 回答