RowState property in System.Data.DataRow class RRS feed

  • Question

  • Hey Guys,

    I'm confused with the modified state in MSDN. Here is what the doc says:

    Modified: the row has been modified but AcceptChanges() has NOT been called.

    Say if you have a clean table which has single column (just for simplicity), and just added a row into it by doing something like table.Rows.Add(originalValue) Now the row sate should be Added.

    Now you modify the row that was just added by doing something like table.Rows[0][0] = currentValue, which should implicitly call BeginEdit()

    Question (1): However, as of now, the row state is still Added rather than being Modified if you do System.Console.WriteLine(table.Rows[0].RowState). Is this kind of contradictory?

    Question (2): If you invoke table.Rows[0].AcceptChanges() now and check the original row by doing Console.WriteLine(table.Rows[0][column, DataRowVersion.Original]), it still prints the currentValue rather than the originalValue.




    Sunday, July 24, 2011 5:25 AM


  • Just figured it out. AcceptChanges() has to be called after Add(...) was invoked
    Bohan Liu
    • Marked as answer by bohanl Sunday, July 24, 2011 5:41 AM
    Sunday, July 24, 2011 5:41 AM