-
Searching ASP .NET Gridview Data - How?
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
Similar Threads
-
By mycwcgr in forum ASP.NET
Replies: 0
Last Post: 10-11-2005, 08:12 AM
-
Replies: 1
Last Post: 05-13-2005, 06:46 AM
-
By Phil Weber in forum .NET
Replies: 632
Last Post: 10-01-2003, 12:00 AM
-
By Edward in forum ASP.NET
Replies: 1
Last Post: 01-09-2002, 02:41 PM
-
By Developer Express in forum dotnet.announcements
Replies: 0
Last Post: 10-06-2001, 02:43 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|