Programatically Set or Change DataRow‘s RowState

Programatically Set or Change DataRow‘s RowState

The .NET Framework 2.0 adds a new feature: SetAdded, SetModified. You use this feature to set DataRow‘s RowState value programatically.

This is applicable only when the current DataRow‘s RowState is Unchanged.

Simply use the following steps:

  1. Make the necessary changes to the DataRow.
  2. Call AcceptChanges() for the DataRow. When invoking AcceptChanges, any DataRow object still in edit mode successfully ends its edit. Each DataRow‘s RowState property also changes; the Added and Modified rows become Unchanged, and the Deleted rows are removed:
    dsCopySess.Tables["DataTableName"].Rows[0].AcceptChanges(); 
  3. Set the RowState as desired:
    dsCopySess.Tables["DataTableName"].Rows[0].SetAdded();
Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular