Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DataRowState Not Working

DataRowState Not Working

Scheduled Pinned Locked Moved C#
databasequestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    polishprogrammer
    wrote on last edited by
    #1

    I have a database application that has a datatable bound to both a DataGridView and some text boxes. The text boxes, collectively, show one row of data. Now, if a user has edited a row and clicks 'Save' in the File menu, I want those changes to be saved. Right now, I'm basing the decision to save or not save a row on whether the DataRowState for that row is 'Modified'. But, if the row the user has edited still has the 'focus', so to speak, the DataRowState is not 'Modified', but 'Unchanged', even if the individual values in the text boxes (to which the data table is bound) have been changed. As soon as I go view another row in the database, though, the DataRowState becomes 'Modified'. Is there an easy way to validate the row without leaving it?

    K 1 Reply Last reply
    0
    • P polishprogrammer

      I have a database application that has a datatable bound to both a DataGridView and some text boxes. The text boxes, collectively, show one row of data. Now, if a user has edited a row and clicks 'Save' in the File menu, I want those changes to be saved. Right now, I'm basing the decision to save or not save a row on whether the DataRowState for that row is 'Modified'. But, if the row the user has edited still has the 'focus', so to speak, the DataRowState is not 'Modified', but 'Unchanged', even if the individual values in the text boxes (to which the data table is bound) have been changed. As soon as I go view another row in the database, though, the DataRowState becomes 'Modified'. Is there an easy way to validate the row without leaving it?

      K Offline
      K Offline
      kragan
      wrote on last edited by
      #2

      Just a guess, but you might try calling the EndEdit method on the DataRow prior to checking its DataRowState.

      P 1 Reply Last reply
      0
      • K kragan

        Just a guess, but you might try calling the EndEdit method on the DataRow prior to checking its DataRowState.

        P Offline
        P Offline
        polishprogrammer
        wrote on last edited by
        #3

        I thought of that, too, but it did not work. When I googled the problem, I found a solution. Basically, if I call the BindManagerBase.EndCurrentEdit() method, that updates the datatable with any changes that are in progress and changes the DataRowState, as appropriate.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups