DataGrid分页问题
//绑定表
Function mydatabind()
Dim con As SqlConnection = DB.con()
Dim MyAdapter As SqlDataAdapter = New SqlDataAdapter
Dim ds As New DataSet
MyAdapter.SelectCommand = New SqlCommand("Select * From clerk where sex='男'", con)
MyAdapter.Fill(ds, "clerk")
'将数据绑定到DataGrid
DataGrid1.DataSource = ds
DataGrid1.DataBind()
End Function
//PageIndexChanged方法
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
Me.DataGrid1.CurrentPageIndex = e.NewPageIndex
Me.mydatabind()
End Sub
运行后,单击下一页出错
“无效的 CurrentPageIndex 值。它必须大于等于 0 且小于 PageCount”