views:

605

answers:

1

I have a Form (Compact Framework, actually) with a few fields, a date and a string, among other things. Both TextBox controls are bound to properties in a BindindSource.

The BindindSource has a DataSet as its DataSource property, and the DataMember is a table in a SQL CE database.

When I want to add a new row, I call bindingSource.AddNew(), then bindingSource.MoveLast(). The form shows the default values (as defined in the DataSet) and I can edit all the fields.

To save the form, I call bindingSource.EndEdit() and insert the values from the DataSet row into the database, using a TableAdapter method. The date makes it into the database, the string does not. Instead, the default value for the string is saved, not the value that I typed in the text box.

When I inspect the data in the DataSet table's row after calling EndEdit(), the date field is updated with the data from the form, the string is not.

Oddly enough, when I edit an existing row with the same form (without calling AddNew), the string field is updated and persisted just fine. So this only happens after calling AddNew() on the BindingSource. What am I missing? Where should I start looking?

The code is a bit too much to post here, unfortunately.

A: 

I found the issue - I had accidentially select the same column in the BindingSource for both the Tag and the Text property of the TextBox. I think what happened was that the Text was written back first, the Tag second, and because the Tag was not updated, it overwrote the modified value.

cdonner