Yvan Site Admin
Joined: 19 Mar 2005 Posts: 721
|
Posted: Wed Nov 16, 2005 7:11 pm Post subject:
Windows Form not binding to DataRow
|
|
|
I ran into this one which stumped me for a couple of days.
I had a valid DataSet that had been loaded with a DataRow by a mysqlDataAdapter.
I had a Windows Form that had several controls bound to the DataRow.
The controls were not binding (they showed their default values).
Eventually I discovered that I was able to force an exception with an error message that helped to explain what was actually going on.
| Code: | this.BindingContext[this.FormData, "Orders"].ResumeBinding();
|
This generated the error
| Quote: | An unhandled exception of type 'System.Exception' occurred in system.windows.forms.dll
Additional information: DataBinding could not find a row in the list that is suitable for all bindings |
Something between the schema and the bound controls was not agreeing. I wasn't able to get a more specific error but I discovered the source of the problem by unbinding each of the controls and rebinding them gradually.
The problem was DateTimePicker controls that had their Value property bound to a DateTime field in the table.
The solution (workaround?) is to bind to the Text property instead of the Value property. This is not documented in the .NET platform SDK. |
|