0
votes

I filtered my BindingSource and can notice the results great on a gridview control that is tied in... but when I iterate through manually, I am not getting expected results. Here is the code:

    CollectorAlertsBindingSource.Filter = "CollectorAlert_Name='" & nameCA & "'"
    Me.CollectorAlertsTableAdapter.Fill(Me.PWDS.CollectorAlerts)

    Dim CARows As DataRow

    For Each CARows In PWDS.CollectorAlerts.Rows
        txtCollectorAlertName.Text = CARows("CollectorAlert_Name").ToString
        txtTimedInterval.Text = CARows("CollectorAlert_TriggerInterval").ToString
    Next

I can tell when I step through the code that the ROWS.Count = 3. There are a total of 3 rows in the table, but the filter should have filtered it down to 1. I'm sure I am looking at this completely wrong, so I need a bit of help.

What am I doing wrong?

Thanks!

1

1 Answers

0
votes

You filtered the BindingSource, but then you're not using it - you're pulling rows directly from the datatable. When you apply a filter, the bs actually filters via its own DataView, (which is a layer that sits on top of the datatable. You can see this in the debugger as the 'syncroot' property of the bs.) The table itself still has all the rows within it.