none
RowStates on Editing Orphan DataRow (Not added to a DataTable Object Yet) RRS feed

  • Question

  • Hello there,

    I have a question that's crossed my mind a couple of times that needs answering as it constantly bugs me ;) .

    I have created a DataTable object for which I am about to add a new DataRow through the NewRow method of the DataTable object.

    Now that I have obtained a row which is not associated with the DataTable ( RowState : Detached ), I am trying to edit it's contents by simply assigning values to the respective columns.

    Is this an instance where I perform an 'implicit execution of the BeginEdit method on an orphaned row (detached state)' ?

    I am trying to properly understand when this implicit execution actually happens. (if the above is not the implicit way it occurs).

    The reason I am trying to do the above is to see a 'VersionNotFound' exception thrown at me for trying to access the 'Proposed' State of this orphan DataRow.

    Many thanks to everyone who tries to help me with a reasonable explanation :)

    Cheers,
    Tharindu.
    • Edited by EvilAngel89 Monday, January 30, 2012 8:46 AM change of content needed
    Monday, January 30, 2012 8:25 AM

All replies

  • Have you checked Robert Rossney comment in the below article

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/cf1b16ef-a980-427f-9e4a-ceccd962b046/

    Monday, January 30, 2012 9:09 AM
  • I just checked. Doesn't look like it answers my question :)

    I am very much aware that the row is not in a collection. What I am looking for is a way that BeginEdit() is performed on the detached row in an implicit sense.
    • Edited by EvilAngel89 Monday, January 30, 2012 11:03 AM
    Monday, January 30, 2012 11:01 AM
  • I think we can, as the Detached means "The row has been created but is not part of any DataRowCollection. A DataRow is in this state immediately after it has been created and before it is added to a collection, or if it has been removed from a collection."

    Please check the below given article

    http://www.koders.com/csharp/fidA057853BF3676CC29BC947AB97DD76A28ABAEA3E.aspx

    Check for the "Proposed" property.

     

    Monday, January 30, 2012 12:39 PM
  • I am trying to properly understand when this implicit execution actually happens. (if the above is not the implicit way it occurs).

    The reason I am trying to do the above is to see a 'VersionNotFound' exception thrown at me for trying to access the 'Proposed' State of this orphan DataRow.

    When and why are you trying to access the 'Proposed" state of this DataRow? Perhaps you could post a little code that illustrates the problem?


    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Sunday, February 5, 2012 5:16 PM