asp.net.ph

DataViewRowState Enumeration

System.Data Namespace


Describes the version of data in a DataRow.

This enumeration has a FlagsAttribute that allows a bitwise combination of its member values.

Members


Member Name Description
Added A new row.
CurrentRows Current rows including unchanged, new, and modified rows.
Deleted A deleted row.
ModifiedCurrent A current version, which is a modified version of original data ( see ModifiedOriginal ).
ModifiedOriginal The original version ( although it has since been modified and is available as ModifiedCurrent ).
None None.
OriginalRows Original rows including unchanged and deleted rows.
Unchanged An unchanged row.

Example

[ C#, VB ] In the following example DataTable is created with a single column. The data and is changed, and the RowStateFilter of the DataView is set to display different row sets, depending on the DataViewRowState.

private void DemonstrateRowState ( ) {
   int i;

   // create a DataTable with one column.
   DataTable myTable = new DataTable ( "myTable" );
   DataColumn myColumn = new DataColumn ( "myColumn" );
   myTable.Columns.Add ( myColumn );

   // add ten rows.
   DataRow myRow;
   for ( i = 0;i < 10 ; i++ ) {
      myRow = myTable.NewRow ( );
      myRow [ "myColumn" ] = "item " + i;
      myTable.Rows.Add ( myRow );
  }
   myTable.AcceptChanges ( );

   // create a DataView with the table.
   DataView myView = new DataView ( myTable );

   // change one row' s value:
   myTable.Rows [ 1 ] [ "myColumn" ] = "Hello";

   // add one row:
   myRow = myTable.NewRow ( );
   myRow [ "myColumn" ] = "World";
   myTable.Rows.Add ( myRow );

   // set the RowStateFilter to display only Added and modified rows.
   myView.RowStateFilter = 
      DataViewRowState.Added | DataViewRowState.ModifiedCurrent;

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

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

   // delete three rows.
   myTable.Rows [ 1 ].Delete ( );
   myTable.Rows [ 2 ].Delete ( );
   myTable.Rows [ 3 ].Delete ( );

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

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

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

   // set filter to display only original rows.
   myView.RowStateFilter = DataViewRowState.OriginalRows;
   PrintView ( myView,"OriginalRows" );
}
private void PrintView ( DataView dv,string label ) {
   Response.Write ( "<br>" + label );
   for ( int i = 0;i < dv.Count ; i++ ) {
      Response.Write ( dv [ ] [ "myColumn" ] );
   }
}
  C# VB

Remarks

The DataViewRowState values are used either to retrieve a particular version of data from a DataRow, or to determine what versions exist.

Set the RowStateFilter property of the DataView to specify which version or versions of data you want to view.

You can use the Boolean operator Or with the values to get more than one version.

The DataTable uses DataViewRowState in the Select method.

See Also

DataRow   DataView   DataView   Select Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph