This documentation is archived and is not being maintained.

DataRow.RowState Property

Gets the current state of the row in regard to its relationship to the DataRowCollection.

[Visual Basic]
Public ReadOnly Property RowState As DataRowState
public DataRowState RowState {get;}
public: __property DataRowState get_RowState();
public function get RowState() : DataRowState;

Property Value

One of the DataRowState values.


The value of the RowState depends on two factors: (1) the kind of operation has been performed on the row, and (2) whether or not AcceptChanges has been called on the DataRow.


[Visual Basic, C#, C++] 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.

[Visual Basic] 
Private Sub DemonstrateRowState()
    ' Run a function to create a DataTable with one column.
    Dim myTable As DataTable = MakeTable()
    Dim myRow As DataRow 
    ' 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)
 End Sub
 Private Function MakeTable() As DataTable
    ' Make a simple table with one column.
    Dim myTable As DataTable = New DataTable("myTable")
    Dim dcFirstName As DataColumn = New DataColumn("FirstName", Type.GetType("System.String"))
    MakeTable = myTable
 End Function

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 myTable = new DataTable("myTable");
    DataColumn dcFirstName = new DataColumn("FirstName", Type.GetType("System.String"));
    return myTable;

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(S"New Row {0}", __box(myRow->RowState));
    // New row.
    Console::WriteLine(S"AddRow {0}", __box(myRow->RowState));
    // Unchanged row.
    Console::WriteLine(S"AcceptChanges {0}", __box(myRow->RowState));
    myRow->Item[S"FirstName"] = S"Scott";
    // Modified row.
    Console::WriteLine(S"Modified {0}", __box(myRow->RowState));
    // Deleted row.
    Console::WriteLine(S"Deleted {0}", __box(myRow->RowState));
 DataTable* MakeTable(){
    // Make a simple table with one column.
    DataTable* myTable = new DataTable(S"myTable");
    DataColumn* dcFirstName = new DataColumn(S"FirstName", Type::GetType(S"System.String"));
    return myTable;

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataRow Class | DataRow Members | System.Data Namespace | AcceptChanges | BeginEdit | Add | CancelEdit | DataTable | DataRowView | Delete | EndEdit | NewRow