none
Bindingsource problem RRS feed

  • Question

  • I'm re-working an old ADO project and updating it to use a datacontext and LINQ to SQL. It is a simple book database and I want to show one book at a time and be able to filter the recordset. For example, show all books read, or all books purchased in 2005 etc.

    I've got buttons for previous and next record etc that all work fine, but filters won't work and the "supportsfilter" property of the bindingsource is set to false.

    I've included some of my code so can somebody explain why filters aren't working on the bindingsource, where I am going wrong in principle, or maybe suggest a better way of doing this ?

    Many thanks . . . .

    Dim db As New DataClassBKSDataContext

    mainbindsource.DataSource = From bks In db.New_Details Select bks

     

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_prev.Click

    mainbindsource.MovePrevious()

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_next.Click

    mainbindsource.MoveNext()

    End Sub


    Private Sub filterdata()

    mainbindsource.filter = "PurchasedYear='2005'"

    End Sub

    Tuesday, February 2, 2010 2:40 PM