如何读取gridview分页中的下一页
在写一个信息采集,遇到用gridview控件分页的网页,我应该如何取出
第二页,第三页的内容,有做过的没有,说下思路
------解决方案--------------------内容是来自于数据源,跟控件没有关系。你难道是先写控件然后才考虑数据源是什么?
通常,不想好数据源是什么,就不太容易确定控件如何与数据源交互。你应该也没有那么高级可以不想盖好1、2层楼房的时候就把3层以上楼房已经盖起来了。
你把工具想的简单、低级一点,各个对象各自执行各自的职责,谁各自提供什么功能搞清楚。不要跑到ui控件里去找低层功能。
------解决方案--------------------Private Shared Sub GridViewPageState(ByVal PageCount As Integer, ByVal PageIndex As Integer, ByVal GridViewBottomPagerRow As GridViewRow, ByVal RecordCount As Integer)
Dim PageInfoLabel As Label = CType(GridViewBottomPagerRow.Cells(0).FindControl( "PageInfoLabel "), Label)
Dim FirstButton As LinkButton = CType(GridViewBottomPagerRow.Cells(0).FindControl( "FirstButton "), LinkButton)
Dim PrevButton As LinkButton = CType(GridViewBottomPagerRow.Cells(0).FindControl( "PrevButton "), LinkButton)
Dim NextButton As LinkButton = CType(GridViewBottomPagerRow.Cells(0).FindControl( "NextButton "), LinkButton)
Dim LastButton As LinkButton = CType(GridViewBottomPagerRow.Cells(0).FindControl( "LastButton "), LinkButton)
Dim PageList As DropDownList = CType(GridViewBottomPagerRow.Cells(0).FindControl( "PageList "), DropDownList)
Try
If PageCount < 2 Then '当数据集为空或只有一页时
PageInfoLabel.Text = " 共 " + RecordCount.ToString + " 条记录 "
FirstButton.Enabled = False
PrevButton.Enabled = False
NextButton.Enabled = False
LastButton.Enabled = False
PageList.Enabled = False
GridViewBottomPagerRow.Visible = True
Exit Sub
End If
PageIndex += 1
PageInfoLabel.Text = " 共 " + RecordCount.ToString + " 条记录 第 " + PageIndex.ToString + "/ " + PageCount.ToString + " 页 "
Select Case PageIndex
Case 1 '首页
FirstButton.Enabled = False
PrevButton.Enabled = False
NextButton.Enabled = True
LastButton.Enabled = True
Case PageCount '末页
FirstButton.Enabled = True
PrevButton.Enabled = True
NextButton.Enabled = False
LastButton.Enabled = False
Case Else
FirstButton.Enabled = True
PrevButton.Enabled = True
NextButton.Enabled = True
LastButton.Enabled = True
End Select
PageList.Enabled = True
Dim PI As Integer
Dim item As New ListItem
For PI = 1 To PageCount
item = New ListItem(PI.ToString)
If PI = PageIndex Then
item.Selected = True
End If
PageList.Items.Add(item)
Next
Catch ex As Exception
Exit Sub
End Try
End Sub