System.Data.DataRow Class

Represents a row of data in a System.Data.DataTable.

See Also: DataRow Members

Syntax

public class DataRow

Remarks

The System.Data.DataRow and System.Data.DataColumn objects are primary components of a System.Data.DataTable. Use the System.Data.DataRow object and its properties and methods to retrieve and evaluate; and insert, delete, and update the values in the System.Data.DataTable. The System.Data.DataRowCollection represents the actual System.Data.DataRow objects in the System.Data.DataTable, and the System.Data.DataColumnCollection contains the System.Data.DataColumn objects that describe the schema of the System.Data.DataTable. Use the overloaded DataRow.Item(int) property to return or set the value of a System.Data.DataColumn.

Use the DataRow.HasVersion(DataRowVersion) and DataRow.IsNull(int) properties to determine the status of a particular row value, and the DataRow.RowState property to determine the state of the row relative to its parent System.Data.DataTable.

To create a new System.Data.DataRow, use the DataTable.NewRow method of the System.Data.DataTable object. After creating a new System.Data.DataRow, use the DataRowCollection.Add(DataRow) method to add the new System.Data.DataRow to the System.Data.DataRowCollection. Finally, call the DataRow.AcceptChanges method of the System.Data.DataTable object to confirm the addition. For more information about adding data to a System.Data.DataTable, see Adding Data to a Table.

You can delete a System.Data.DataRow from the System.Data.DataRowCollection by calling the DataRowCollection.Remove(DataRow) method of the System.Data.DataRowCollection, or by calling the DataRow.Delete method of the System.Data.DataRow object. The DataRowCollection.Remove(DataRow) method removes the row from the collection. In contrast, DataRow.Delete marks the System.Data.DataRow for removal. The actual removal occurs when you call DataRow.AcceptChanges method. By calling DataRow.Delete, you can programmatically check which rows are marked for removal before actually deleting them. For more information, see Deleting a Row from a Table.

Requirements

Namespace: System.Data
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0, 2.0.0.0