Binding lost after refreshing
Posted on 2001-09-02
Why do my bound controls lose binding relation to my data source control after the data source control?s recordset refreshed?
In my project, I need my own data source control instead of data control provided by MS ADO to provide special business rules control. In my test usercontrol (looks exactly like the adodc control), I successfully got my recordset bound to appropriate data consumers, among which there?s a datagrid. It looks everything is fine when I move from record to record, or do addnew, update, begintrans, committrans and rollbacktrans. But there?s a very ugly problem. When my operation to the data source involves refreshing (rs.close and rs.open), the bound controls will lose binding relation to the data source and they will act on themselves with the old recordset no matter how the data source is doing. When the datagrid moves from row to row, other bound controls will change respectively. From the debug messages printed in the data source?s events, I know the data source control itself works very normally except not controlling the bound controls any more.
I guess I need to do something like updatecontrols in an appropriate event to inform the bound controls that I have refreshed the recordset. But I don?t know how to do it. I don?t know if there?s any other way than getdatamember that can establish or reestablish the relation between a data source and a data consumer. I also consider it?s very ugly if I have to programmatically bind data consumers one by one. I hope there?s some convenient way to tell the data consumers themselves to do the binding again.
So please teach me why the binding is lost and how to resolve it.
Thanks in advance.