Edits on DataRow not visible

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Amey

    #1

    Edits on DataRow not visible

    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.


  • Cor Ligthert

    #2
    Re: Edits on DataRow not visible

    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)).E ndCurrentEdit()

    I hope this helps a little bit?

    Cor


    Comment

    • Steve Amey

      #3
      Re: Edits on DataRow not visible

      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).EndCurr entEdit(), it works fine.

      Cheers.
      Steve.

      "Cor Ligthert" <notmyfirstname @planet.nl> wrote in message
      news:efXfk8oaFH A.2848@TK2MSFTN GP10.phx.gbl...[color=blue]
      > 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)).E ndCurrentEdit()
      >
      > I hope this helps a little bit?
      >
      > Cor
      >[/color]


      Comment

      Working...