[求助]分页问题
请问各位救救小弟!!!!!!!!!!!!!!!我搞了几天了!!!!!!Sub DataGrid1_Page(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
Dim startIndex As Integer
startIndex = Datagrid1.CurrentPageIndex * Datagrid1.PageSize
Datagrid1.CurrentPageIndex = e.NewPageIndex
CreateData()
ShowStats()
End Sub
Sub ShowStats()
lblCurrentIndex.Text = "第 " + (Datagrid1.CurrentPageIndex + 1).ToString() + " 页"
lblPageCount.Text = "总共 " + Datagrid1.PageCount.ToString() + " 页"
If Datagrid1.CurrentPageIndex + 1 <> 1 Then
Datagrid2.Visible = False
End If
End Sub
Sub PagerButtonClick(ByVal sender As Object, ByVal e As EventArgs)
Dim arg As String = sender.CommandArgument
Select Case arg
Case "next"
If (Datagrid1.CurrentPageIndex < (Datagrid1.PageCount - 1)) Then
Datagrid1.CurrentPageIndex += 1
End If
Case "prev"
If (Datagrid1.CurrentPageIndex > 0) Then
Datagrid1.CurrentPageIndex -= 1
End If
Case "last"
Datagrid1.CurrentPageIndex = (Datagrid1.PageCount - 1)
Case Else
'Page(number)
Datagrid1.CurrentPageIndex = System.Convert.ToInt32(arg)
End Select
CreateData()
ShowStats()
End Sub
我的datagrid..PageSize设了5而我有12条记录.....怎么老是显示只有1页......
Dim startIndex As Integer
startIndex = Datagrid1.CurrentPageIndex * Datagrid1.PageSize
Datagrid1.CurrentPageIndex = e.NewPageIndex
CreateData()
ShowStats()
End Sub
Sub ShowStats()
lblCurrentIndex.Text = "第 " + (Datagrid1.CurrentPageIndex + 1).ToString() + " 页"
lblPageCount.Text = "总共 " + Datagrid1.PageCount.ToString() + " 页"
If Datagrid1.CurrentPageIndex + 1 <> 1 Then
Datagrid2.Visible = False
End If
End Sub
Sub PagerButtonClick(ByVal sender As Object, ByVal e As EventArgs)
Dim arg As String = sender.CommandArgument
Select Case arg
Case "next"
If (Datagrid1.CurrentPageIndex < (Datagrid1.PageCount - 1)) Then
Datagrid1.CurrentPageIndex += 1
End If
Case "prev"
If (Datagrid1.CurrentPageIndex > 0) Then
Datagrid1.CurrentPageIndex -= 1
End If
Case "last"
Datagrid1.CurrentPageIndex = (Datagrid1.PageCount - 1)
Case Else
'Page(number)
Datagrid1.CurrentPageIndex = System.Convert.ToInt32(arg)
End Select
CreateData()
ShowStats()
End Sub