Databinding to controls not working

5 posts, 0 answers
  1. Roger
    Roger avatar
    22 posts
    Member since:
    Nov 2017

    Posted 12 Dec 2017 Link to this post

    Hi I have all the telerik controls on a form databound like the following

    Me.txtTitleDetails.DataBindings.Add(New Binding("Text", bsClient, "title_other"))

     

    where bsClient is a BindingSource. The datasource of bsClient is an on form dataset control of multiple table & I use the first one for the controls on the form.

    bsClient.DataSource = dsClientDetails.Tables(0)

    Everything works fine when the datasource is loaded and then the controls bound...but if I change the contents of the dataset (with the same table structure but different data) the forms won't repopulate with the new data ???

    have tried bsClient.ResetBindings(True/False) and the currencymanager

    Dim myCurrencyManager As CurrencyManager = CType(Me.BindingContext(bsClient), CurrencyManager)
            myCurrencyManager.Refresh()

     

    but still no luck..I would really like to use the databinding for data validation/change detection....do you have any ideas?

     

     

  2. Dimitar
    Admin
    Dimitar avatar
    2949 posts

    Posted 13 Dec 2017 Link to this post

    Hi Roger,

    I have tested this and it appears to work on my side. For convenience, I prepared a small sample, based on the information that you provided so far and attached it to this thread. Could you please check it and let me know how it differs from your real setup? 

    I am looking forward to your reply.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Roger
    Roger avatar
    22 posts
    Member since:
    Nov 2017

    Posted 13 Dec 2017 in reply to Dimitar Link to this post

    Hi Dimitar

    yep that worked now I have sent you a mofified version that uses a bindingsource.datasource of a dataset and update the tables on the dataset...this doesn't update the form text.

    What I have done to solve the problem is to remove all the control binding and rebind them again...then it works...clunky but works.

    Seems there is some event missing between updating the dataset and the bindingsource updating the controls that is not being communicated...the attached file is a zip file but have named it png to get passed the validation.

  4. Roger
    Roger avatar
    22 posts
    Member since:
    Nov 2017

    Posted 13 Dec 2017 in reply to Roger Link to this post

    Hi again

    you got me thinking...& found this in the Bindingsource documentation

    When setting a data source, if the supplied reference contains more than one list or table, you must set the DataMember property to a string that specifies the list to bind to. Setting this property raises the DataSourceChanged event.

    I changed both button_clicks to finish with the line

    bs.DataMember = "Drugs"

     

    and it works...that fired the event to refresh the form...now to test it on the main form...

     

    Thanks for the help

     

  5. Dimitar
    Admin
    Dimitar avatar
    2949 posts

    Posted 14 Dec 2017 Link to this post

    Hello Roger,

    In this case, the binding source would not receive any notification that the tables are changed and there is no proper way to refresh the bindings. I would recommend instead of changing the tables to manually update the table which is already bound. In this case, the binding source will listen for changes and it will update the controls. Here is an example:
    Dim Table = dsDrugs.Tables(0)
    Table.Rows.Clear()
     
    For Each item As DataRow In GetTable1().Rows
        Table.ImportRow(item)
     
    Next item

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top