updating & saving bound data

HI,

Ive got a customer datagrid whos' datasource is a CustomersBindingSource.

I also have several texboxes that reflect the grids data and changes when different row is selected on the Datagrid using the same CustomersBindingSource but each textbox has a specific DB column associated with it (Firstname lastname etc..)

I have a save button onclick event that has this code in it.

Me.CustomersTableAdapter.Update(Me.DataSet1.customers)

The save dosent seem to be working correctly unless I leave the current row of the datagrid then click the save button. I think I'm missing somthing but don't know what.

If I leave the current row and return the data remains as I changed it but not saved in the DB.

If I leave the current row then click save the BD is updated.

Is this normal? Should I just write some code to mailine the updates right into the DB.

Thanks.

[1085 byte] By [dashley] at [2007-12-22]
# 1

Yes, this is normal. Data from bound controls (e.g. text boxes) is submitted to data source (DataSet in this case) on validation event by default so unless you have such event data would never make it into the data source. Changing current row in the grid calls EndEdit() on current row which would also submit changes. You can do the same (call EndEdit()) as you click "Save" button.

IlyaTumanov at 2007-8-30 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...