DataView.RowStateFilter Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets the row state filter used in the DataView.

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

public DataViewRowState RowStateFilter { get; set; }

Property Value

Type: System.Data.DataViewRowState

One of the DataViewRowState values.

Only rows that have been deleted by using the Delete method will have their RowStateFilter value set to Deleted. Those rows added using the AddNew method will similarly have the property set to Added.


 Using the Remove method of the DataRowCollection class does not mean that a row will be marked as Deleted. Use the Delete method instead to make sure that such rows can be viewed in the DataView.

New rows will also be visible when the RowStateFilter is set to ModifiedCurrent or CurrentRows.

Deleted rows will also be visible when the RowStateFilter is set to ModifiedOriginal and OriginalRows.

The following example creates a DataTable with a single column, and then changes the data and sets the RowStateFilter of the DataView to display different row sets, depending on the DataViewRowState.

static private void DemonstrateRowState()
    // Create a DataTable with one column.
    DataTable dataTable = new DataTable("dataTable");
    DataColumn dataColumn = new DataColumn("dataColumn");

    // Add ten rows.
    DataRow dataRow;
    for (int i = 0; i < 10; i++)
        dataRow = dataTable.NewRow();
        dataRow["dataColumn"] = "item " + i;

    // Create a DataView with the table.
    DataView dataView = new DataView(dataTable);

    // Change one row's value:
    dataTable.Rows[1]["dataColumn"] = "Hello";

    // Add one row:
    dataRow = dataTable.NewRow();
    dataRow["dataColumn"] = "World";

    // Set the RowStateFilter to display only added and modified rows.
    dataView.RowStateFilter = DataViewRowState.Added
        | DataViewRowState.ModifiedCurrent;

    // Print those rows. Output = "Hello" "World";
    PrintView(dataView, "ModifiedCurrent and Added");

    // Set filter to display on originals of modified rows.
    dataView.RowStateFilter = DataViewRowState.ModifiedOriginal;
    PrintView(dataView, "ModifiedOriginal");

    // Delete three rows.

    // Set the RowStateFilter to display only Added and modified rows.
    dataView.RowStateFilter = DataViewRowState.Deleted;
    PrintView(dataView, "Deleted");

    //Set filter to display only current.
    dataView.RowStateFilter = DataViewRowState.CurrentRows;
    PrintView(dataView, "Current");

    // Set filter to display only unchanged rows.
    dataView.RowStateFilter = DataViewRowState.Unchanged;
    PrintView(dataView, "Unchanged");

    // Set filter to display only original rows.
    dataView.RowStateFilter = DataViewRowState.OriginalRows;
    PrintView(dataView, "OriginalRows");

static private void PrintView(DataView dataView, string label)
    Console.WriteLine("\n" + label);
    for (int i = 0; i < dataView.Count; i++)

.NET Framework
Available since 1.1
Return to top