Need Help filtering with DataRepeater

51 Views Asked by At

My form allows the user to search a collection of customers. When I click on the Search button I want it to display only the specific result that was found and hide the rest of the customers.

For example, if I put customer id as 133 it should only show that one and hide the rest.

Private Sub SearchButton_Click(sender As Object, e As EventArgs) Handles SearchButton.Click
    Dim foundIndex As Integer
    Dim searchString As String
    searchString = SearchTextBox.Text
    foundIndex = CustomerRecBindingSource.Find("customerid", searchString)
    If foundIndex > -1 Then
        DataRepeater1.CurrentItemIndex = foundIndex
    Else
        MsgBox("Item " & searchString & " not found.")
    End If
End Sub

This version only brings the search results to the top. It doesn't hide the rest of the data.

I tried changing the line:

DataRepeater1.CurrentItemIndex = foundIndex

to

DataRepeater1.CurrentItem = foundIndex

but then I get the error Property 'Current Item' is 'Read Only'

0

There are 0 best solutions below