DataRowState Enumeration
Collapse the table of content
Expand the table of content

DataRowState Enumeration


Gets the state of a DataRow object.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

public enum DataRowState

Member nameDescription

The row has been added to a DataRowCollection, and AcceptChanges has not been called.


The row was deleted using the Delete method of the DataRow.


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.


The row has been modified and AcceptChanges has not been called.


The row has not changed since AcceptChanges was last called.

The DataRowState enumeration is returned by the RowState property of the DataRow class.

The following example first creates a new DataTable with one column, then creates a single DataRow. As the DataRow is created, added, modified, and deleted, its RowState is printed.

private void DemonstrateRowState() {
   //Run a function to create a DataTable with one column.
   DataTable myTable = MakeTable();
   DataRow myRow;

   // Create a new DataRow.
   myRow = myTable.NewRow();
   // Detached row.
   Console.WriteLine("New Row " + myRow.RowState);

   // New row.
   Console.WriteLine("AddRow " + myRow.RowState);

   // Unchanged row.
   Console.WriteLine("AcceptChanges " + myRow.RowState);

   myRow["FirstName"] = "Scott";
   // Modified row.
   Console.WriteLine("Modified " + myRow.RowState);

   // Deleted row.
   Console.WriteLine("Deleted " + myRow.RowState);

private DataTable MakeTable(){
   // Make a simple table with one column.
   DataTable dt = new DataTable("myTable");
   DataColumn dcFirstName = new DataColumn("FirstName", Type.GetType("System.String"));
   return dt;

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft