I am trying to perform a search on all columns in a databound multiple-page gridview. I would think setting the page index and the row would do the trick (as illustrated by the code below). The data being returned is always from the first page of the grid. Is there a way to get to the data beyond the fist page?


CODE EXAMPLE:

Imports Microsoft.VisualBasic

Public Class GridView
Private mygrid As System.Web.UI.WebControls.GridView

Public Property Grid() As System.Web.UI.WebControls.GridView
Get
Grid = myGrid
End Get
Set(ByVal value As System.Web.UI.WebControls.GridView)
myGrid = value
End Set
End Property

Public Function SeachGrid(ByVal searchForText As String, ByVal searchSpecificColumns() As Integer, ByVal SearchAllColumns As Boolean, ByVal typeOfMatch As Integer, ByRef locatedPage As Integer, ByRef locatedRow As Long, ByRef locatedColumn As Integer) As Boolean
Dim gridRows As Long = mygrid.Rows.Count
Dim gridRow As Integer
Dim gridCol As Integer
Dim totalPages As Integer
Dim totalRows As Integer
Dim pageIndex As Integer
Dim rowIndex As Integer
Dim upperSearchForText As String = UCase(searchForText)
If SearchAllColumns = True Then
Dim ix As Integer
ReDim searchSpecificColumns(mygrid.Columns.Count)
For ix = 0 To mygrid.Columns.Count - 1
searchSpecificColumns(ix) = ix
Next
End If

totalPages = mygrid.PageCount - 1
For pageIndex = 0 To totalPages
mygrid.PageIndex = pageIndex
For gridRow = 0 To mygrid.Rows.Count - 1
rowIndex = rowIndex + 1
For gridCol = 0 To UBound(searchSpecificColumns) - 1
System.Diagnostics.Debug.Print(mygrid.Rows(gridRow).Cells(gridCol).Text)
If InStr(UCase(mygrid.Rows(gridRow).Cells(gridCol).Text), upperSearchForText) > 0 Then
locatedPage = mygrid.PageIndex
locatedRow = gridRow
locatedColumn = gridCol
Return True
End If
Next
Next
Next
Return False
End Function



End Class