Search API form - display to a DataGrid
[This is VB version]
findinsite-ms has a
Search API web service - a programmer interface to the search engine
that can be used over the internet.
This ASP.NET example shows a search form and displays the results in a DataDrid
control, displaying 10 hits at a time. This approach is familiar as this is how
most search engines display their results - although the layout could be
If you do a search for * here (ie to find all possible hits) then the
page should return quickly because only 10 results have to be returned to your
browser. The same search done in Example 1
could take a long time over a slow connection because hundreds of results have
to be returned. However, see the Information
Flows section for a full discussion of possible delays.
The results are cached in a Session variable so that requests for another set
of hits can be fulfilled without having to call the Search API.
Try out the search form - then see below for programming
The example works in exactly the same way as
Example 1 so full programming details are not shown.
methods are largely the same. However
the DataGrid page index to zero, and stores the result in the "fisSearchResult"
HitDataGrid.CurrentPageIndex = 0
Session("fisSearchResult") = result
HitDataGrid DataGrid control is used in a very similar way to
the Repeater control in example 1, ie the
array is set as its DataSource. The DataGrid control PageIndexChanged event is
set to the new script method
Private Sub Page_Change(sender As Object, e As DataGridPageChangedEventArgs)
' Set CurrentPageIndex to the page the user clicked.
HitDataGrid.CurrentPageIndex = e.NewPageIndex
Dim result As fisClient.fisSearchResult
result = Session("fisSearchResult")
if result is Nothing Then
result = new fisClient.fisSearchResult()
result.Message = "Session did not store fisSearchResult"
Catch ex As Exception
This code sets the DataGrid control CurrentPageIndex, retrieves the result from
the Session variable, and calls
ShowResults() as before.
The example can be enhanced easily to cope if the Session has expired.