This documentation is archived and is not being maintained.

DataRows and DataRowViews (ADO.NET)

A DataView exposes an enumerable collection of DataRowView objects. The DataRowView objects expose values as object arrays that are indexed by either the name or the ordinal reference of the column in the underlying table. You can access the DataRow that is exposed by the DataRowView by using the Row property of the DataRowView.

When you view values by using a DataRowView, the RowStateFilter property of the DataView determines which row version of the underlying DataRow is exposed. For information about accessing different row versions using a DataRow, see Row States and Row Versions.

The following code example displays all the current and original values in a table.

DataView catView = new DataView(catDS.Tables["Categories"]);
Console.WriteLine("Current Values:");
Console.WriteLine("Original Values:");
catView.RowStateFilter = DataViewRowState.ModifiedOriginal;

public static void WriteView(DataView thisDataView)
  foreach (DataRowView rowView in thisDataView)
    for (int i = 0; i < thisDataView.Table.Columns.Count; i++)
      Console.Write(rowView[i] + "\t");