DataRowView Class
TOC
Collapse the table of content
Expand the table of content

DataRowView Class

 

Represents a customized view of a DataRow.

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

System.Object
  System.Data.DataRowView

public class DataRowView : ICustomTypeDescriptor, IEditableObject, 
	IDataErrorInfo, INotifyPropertyChanged

NameDescription
System_CAPS_pubpropertyDataView

Gets the DataView to which this row belongs.

System_CAPS_pubpropertyIsEdit

Indicates whether the row is in edit mode.

System_CAPS_pubpropertyIsNew

Indicates whether a DataRowView is new.

System_CAPS_pubpropertyItem[Int32]

Gets or sets a value in a specified column.

System_CAPS_pubpropertyItem[String]

Gets or sets a value in a specified column.

System_CAPS_pubpropertyRow

Gets the DataRow being viewed.

System_CAPS_pubpropertyRowVersion

Gets the current version description of the DataRow.

NameDescription
System_CAPS_pubmethodBeginEdit()

Begins an edit procedure.

System_CAPS_pubmethodCancelEdit()

Cancels an edit procedure.

System_CAPS_pubmethodCreateChildView(DataRelation)

Returns a DataView for the child DataTable with the specified child DataRelation.

System_CAPS_pubmethodCreateChildView(DataRelation, Boolean)

Returns a DataView for the child DataTable with the specified DataRelation and parent..

System_CAPS_pubmethodCreateChildView(String)

Returns a DataView for the child DataTable with the specified child DataRelation name.

System_CAPS_pubmethodCreateChildView(String, Boolean)

Returns a DataView for the child DataTable with the specified DataRelation name and parent.

System_CAPS_pubmethodDelete()

Deletes a row.

System_CAPS_pubmethodEndEdit()

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.

System_CAPS_pubmethodEquals(Object)

Gets a value indicating whether the current DataRowView is identical to the specified object.(Overrides Object.Equals(Object).)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Returns the hash code of the DataRow object.(Overrides Object.GetHashCode().)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubeventPropertyChanged

Event that is raised when a DataRowView property is changed.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetAttributes()

Returns a collection of custom attributes for this instance of a component.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetClassName()

Returns the class name of this instance of a component.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetComponentName()

Returns the name of this instance of a component.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetConverter()

Returns a type converter for this instance of a component.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetDefaultEvent()

Returns the default event for this instance of a component.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetDefaultProperty()

Returns the default property for this instance of a component.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEditor(Type)

Returns an editor of the specified type for this instance of a component.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEvents()

Returns the events for this instance of a component.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEvents(Attribute[])

Returns the events for this instance of a component with specified attributes.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetProperties()

Returns the properties for this instance of a component.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetProperties(Attribute[])

Returns the properties for this instance of a component with specified attributes.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor)

Returns an object that contains the property described by the specified property descriptor.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDataErrorInfo.Error

Gets a message that describes any validation errors for the object.

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDataErrorInfo.Item[String]

Gets the error message for the property with the given name.

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. (See RowFilter for another example using 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
Available since 1.1

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

Return to top
Show:
© 2016 Microsoft