Sign up to the jQuery Grid Subscription list.

Problem applying a filter to binding source

The original post by Kelly R. Martin at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1013527&SiteID=1

The question:

Upon updateing a combobox to select the sex of a farm animal I am attempting to filter out the opposite sex in the next ID box.Can anyone see where my issue is here. I have rewritten this many time to no avail. I have read through the msdn help on this and all appears to be done correctly. Also... How would I use one of these filters to show only discrete items?

http://imkaudio.com/error/nocolumnerror.bmp

And here is the code

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'TODO: This line of code loads data into the 'Ct10DataSet.animal' table. You can move, or remove it, as needed.

Me.AnimalTableAdapter.Fill(Me.Ct10DataSet.animal)

End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

Me.AnimalBindingSource1.Filter = "Sex = " & ComboBox1.SelectedValue.ToString()

End Sub

End Class


The Accepted answer by ahmedilyas :

try this:

Me.AnimalBindingSource1.Filter = "Sex = '" & ComboBox1.Text & "'"

0 comments:

Related Ads