Submitting updates from a datagrid

C

Cory Burkhardt

I have a datagrid that the user can use to edit a dataset (through a
dataview that prevents adding rows). However, there is a problem in that
the row that the user is currently working with does not get submitted to
the dataset until another row is selected. If the user modifies a row in
the data grid and then closes the form, the row in the dataset still shows
as being unchanged and so the changes cannot be submitted to the database.
How can I get the datagrid to save the changes of the row currently being
modified back to the datasource?
 
G

Guest

Hi Cory,

You need to end the current edit by calling EndCurrentEdit on the binding
context before updating the database.

Eg:
Me.BindingContext(<your data source>).EndCurrentEdit()

Let me know if you need more help.

HTH,
Rakesh Rajan
 
C

Cory Burkhardt

I actually found the EndCurrentEdit() method in my documentation, however it
says "if the data source is either a DataView or DataTable, use the
DataRowView class's EndEdit method." Since I am using a DataView, I
followed this guideline. However, I am still having issues with the
datagrid sending updates to the dataview (and from there to the dataset).
In my application, if I modify a cell in the datagrid and then click on a
listbox, from within the SelectedIndexChanged event handler, the
modifications have already been submitted to the dataset. However, if I
modify a cell and then click on the windows close button, from within the
Closing event handler, the modifications have not been submitted. Moreover,
calling EndEdit on the current DataRowView does not send the modifications
to the dataset. Curiously enough, though, the current DataRowView does
indicate that it is in edit mode from within the Closing event handler. So
I am not sure:
- why updates are already submitted from within the listbox's event
handler and not from within the form's closing handler.
- why the DataRowView is in edit mode when entering the form's closing
handler, but calling EndEdit, which ends the edit mode, does not submit any
updates.
 
G

Guest

Hi Cory,

Do you mean that you have added EndEdit in the closing event handler. Are
you sure that you have specified the binding context correctly - it should be
the same way as you have bound the datagrid.

HTH,
Rakesh Rajan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top