Binding a single DataRow to form members
Hi!
I use a popup form to edit a single row of a DataTable.
This is how i open the popup
System.Data.DataRow oNewRow = oDataTableObject.NewRow();
oDataTableObject.Rows.Add(oNewRow);
// Pass the row object to the constructor of the popup form
MyForm oFrmDialog = new MyForm(oNewRow);
oFrmDialog.ShowDialog(this);
In the popup form i add some databindings. i.e.:
//Note: oEditRow is the DataRow object passed over to the constructor
//while instantiating the popup form
Binding dbComment = new Binding("Text", oEditRow["comment"],"" );
dbComment.Format += new ConvertEventHandler(NullToEmptyString);
dbComment.Parse += new ConvertEventHandler(EmptyStringToNull);
this.txtComment.DataBindings.Add(dbComment )
And here is the Problem:
When i edit the text box txtComment, any change i make is resetted when i leave the text box. In ecample i type in 'Foo Bar'. When the focus moves to another control, the conten of the text box is reset to en empty string.
Thanks in advance
Gernot