This is a migrated thread and some comments may be shown as answers.

Databinding to controls not working

4 Answers 155 Views
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 1
Roger asked on 13 Dec 2017, 04:02 AM

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?

 

 

4 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 13 Dec 2017, 07:55 AM
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.
0
Roger
Top achievements
Rank 1
answered on 13 Dec 2017, 11:10 PM

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.

0
Roger
Top achievements
Rank 1
answered on 13 Dec 2017, 11:27 PM

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

 

0
Dimitar
Telerik team
answered on 14 Dec 2017, 09:32 AM
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.
Asked by
Roger
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Roger
Top achievements
Rank 1
Share this question
or