1 out of 2 rated this helpful - Rate this topic

DataRowView Class

Represents a customized view of a DataRow.

System.Object
  System.Data.DataRowView

Namespace:  System.Data
Assembly:  System.Data (in System.Data.dll)
public class DataRowView : ICustomTypeDescriptor, 
	IEditableObject, IDataErrorInfo, INotifyPropertyChanged

The DataRowView type exposes the following members.

  Name Description
Public property Supported by the XNA Framework DataView Gets the DataView to which this row belongs.
Public property Supported by the XNA Framework IsEdit Indicates whether the row is in edit mode.
Public property Supported by the XNA Framework IsNew Indicates whether a DataRowView is new.
Public property Supported by the XNA Framework Item[Int32] Gets or sets a value in a specified column.
Public property Supported by the XNA Framework Item[String] Gets or sets a value in a specified column.
Public property Supported by the XNA Framework Row Gets the DataRow being viewed.
Public property Supported by the XNA Framework RowVersion Gets the current version description of the DataRow.
Top
  Name Description
Public method Supported by the XNA Framework BeginEdit Begins an edit procedure.
Public method Supported by the XNA Framework CancelEdit Cancels an edit procedure.
Public method Supported by the XNA Framework CreateChildView(DataRelation) Returns a DataView for the child DataTable with the specified child DataRelation.
Public method Supported by the XNA Framework CreateChildView(String) Returns a DataView for the child DataTable with the specified child DataRelation name.
Public method Supported by the XNA Framework Delete Deletes a row.
Public method Supported by the XNA Framework EndEdit Commits changes to the underlying DataRow and ends the editing session that was begun with BeginEdit(). Use CancelEdit() to discard the changes made to the DataRow.
Public method Supported by the XNA Framework Equals Gets a value indicating whether the current DataRowView is identical to the specified object. (Overrides Object.Equals(Object).)
Protected method Supported by the XNA Framework Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method Supported by the XNA Framework GetHashCode Returns the hash code of the DataRow object. (Overrides Object.GetHashCode().)
Public method Supported by the XNA Framework GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method Supported by the XNA Framework MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by the XNA Framework ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Public event Supported by the XNA Framework PropertyChanged Event that is raised when a DataRowView property is changed.
Top
  Name Description
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetAttributes For a description of this member, see ICustomTypeDescriptor.GetAttributes.
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetClassName For a description of this member, see ICustomTypeDescriptor.GetClassName.
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetComponentName For a description of this member, see ICustomTypeDescriptor.GetComponentName.
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetConverter For a description of this member, see ICustomTypeDescriptor.GetConverter.
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetDefaultEvent For a description of this member, see ICustomTypeDescriptor.GetDefaultEvent.
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetDefaultProperty For a description of this member, see ICustomTypeDescriptor.GetDefaultProperty.
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetEditor Returns an editor of the specified type for this instance of a component.
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetEvents() For a description of this member, see ICustomTypeDescriptor.GetEvents.
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetEvents(Attribute[]) For a description of this member, see ICustomTypeDescriptor.GetEvents.
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetProperties() For a description of this member, see ICustomTypeDescriptor.GetProperties.
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetProperties(Attribute[]) For a description of this member, see ICustomTypeDescriptor.GetProperties.
Explicit interface implemetation Private method Supported by the XNA Framework ICustomTypeDescriptor.GetPropertyOwner Returns an object that contains the property described by the specified property descriptor.
Explicit interface implemetation Private property Supported by the XNA Framework IDataErrorInfo.Error For a description of this member, see IDataErrorInfo.Error.
Explicit interface implemetation Private property Supported by the XNA Framework IDataErrorInfo.Item Gets the error message for the property with the given name.
Top

Whenever data is displayed, such as in a DataGrid control, only one version of each row can be displayed. The displayed row is a DataRowView.

A DataRowView can have one of four different version states: Default, Original, Current, and Proposed.

After invoking BeginEdit on a DataRow, any edited value becomes the Proposed value. Until either CancelEdit or EndEdit is invoked, the row has an Original and a Proposed version. If CancelEdit is invoked, the proposed version is discarded, and the value reverts to Original. If EndEdit is invoked, the DataRowView no longer has a Proposed version; instead, the proposed value becomes the current value. Default values are available only on rows that have columns with default values defined.

The following example uses the RowVersion property to determine the state of a row in the DataRowView.


private static void DemonstrateRowVersion()
{
    // Create a DataTable with one column.
    DataTable table = new DataTable("Table");
    DataColumn column = new DataColumn("Column");
    table.Columns.Add(column);

    // Add ten rows.
    DataRow row;
    for (int i = 0; i < 10; i++)
    {
        row = table.NewRow();
        row["Column"] = "item " + i;
        table.Rows.Add(row);
    }

    table.AcceptChanges();
    // Create a DataView with the table.
    DataView view = new DataView(table);

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

    // Add one row:
    row = table.NewRow();
    row["Column"] = "World";
    table.Rows.Add(row);

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

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

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

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

    // Set the RowStateFilter to display only deleted rows.
    view.RowStateFilter = DataViewRowState.Deleted;
    PrintView(view, "Deleted");

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

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

    // Set filter to display only original rows.
    // Current values of unmodified rows are also returned.
    view.RowStateFilter = DataViewRowState.OriginalRows;
    PrintView(view, "OriginalRows");
}

private static void PrintView(DataView view, string label)
{
    Console.WriteLine("\n" + label);
    for (int i = 0; i < view.Count; i++)
    {
        Console.WriteLine(view[i]["Column"]);
        Console.WriteLine("DataViewRow.RowVersion: {0}", 
            view[i].RowVersion);
    }
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

This type is safe for multithreaded read operations. You must synchronize any write operations.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ