Edits on DataRow not visible

  • Thread starter Thread starter Steve Amey
  • Start date Start date
S

Steve Amey

Hi all

I am binding a DataRow to some controls on a form. When I've finished
editing the DataRow I click on a toolbar button to save the changes. If the
focus is on a particular control, the item in the DataRow does not update to
be the value of the control, for example, if I have a TextBox called
txtEntry which is bound to the Entry column of the DataRow, if the focus
remains on the TextBox while I click on the save button the DataRow("Entry")
is DBNull.

When the control loses focus, the DataRow is updated with the correct value,
so I'm left with a scenario when the users have to shift focus off the last
control before saving the data, which is obviously not a good thing. I have
tried calling the DataRow.EndEdit before the save but it still didn't update
with the correct value.

Has anyone else come across this behaviour? How do I deal with updating the
DataRow when the bound control does not lose focus before the save is made?

Kind Regards,
Steve.
 
Steve,

This question is absolute in the top hundred of the most asked/answered
questions.

Use endcurrentedit to push the data to the underlaying datasource.

Something as
BindingContext(ds.Tables(0)).EndCurrentEdit()

I hope this helps a little bit?

Cor
 
Hi Cor

Thank you for your response.

I have seen this before, but what made my situation slightly different is
that I do not have a DataTable, I just have a DataRow. I tried creating a
Currency Manager object by doing Dim oCM As CurrencyManager =
BindingContext(m_oRow), but was getting an invalid cast exception, however,
if I use your code snippett below and just change it to
BindingContext(m_oRow).EndCurrentEdit(), it works fine.

Cheers.
Steve.
 
Back
Top