Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataTable::Rows Property

 

Gets the collection of rows that belong to this table.

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

public:
[BrowsableAttribute(false)]
property DataRowCollection^ Rows {
	DataRowCollection^ get();
}

Property Value

Type: System.Data::DataRowCollection^

A DataRowCollection that contains DataRow objects; otherwise a null value if no DataRow objects exist.

To create a new DataRow, you must use the NewRow method to return a new object. Such an object is automatically configured according to the schema defined for the DataTable through its collection of DataColumn objects. After creating a new row and setting the values for each column in the row, add the row to the DataRowCollection using the Add method.

Each DataRow in the collection represents a row of data in the table. To commit a change to the value of a column in the row, you must invoke the AcceptChanges method.

The following shows two examples of returning and setting rows. The first example uses the Rows property and prints the value of each column for every row. The second example uses the DataTable object's NewRow method to create a new DataRow object with the schema of the DataTable. After setting the row values, the row is added to the DataRowCollection through the Add method.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft