asp.net.ph

DataRowCollection Class

System.Data Namespace


Represents a collection of rows for a DataTable.

DataRowCollection Class Members

Collapse   Properties

Visibility Name Value Type Accessibility
public Count Int32 [ Get ]
public Item ( Int32 index ) DataRow [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public Add ( Object values ) DataRow
public Add ( DataRow row ) Void
public Clear ( ) Void
public Contains ( Object key ) Boolean
public Contains ( Object keys ) Boolean
public CopyTo ( DataRow array , Int32 index ) Void
public CopyTo ( Array ar , Int32 index ) Void
public Find ( Object key ) DataRow
public Find ( Object keys ) DataRow
public GetEnumerator ( ) IEnumerator
public IndexOf ( DataRow row ) Int32
public InsertAt ( DataRow row , Int32 pos ) Void
public Remove ( DataRow row ) Void
public RemoveAt ( Int32 index ) Void

Remarks

The DataRowCollection is a major component of the DataTable class, and is accessed via the DataTable.Rows property.

While the DataColumnCollection defines the schema of the table, the DataRowCollection contains the actual data for the table, where each DataRow in the DataRowCollection represents a single row.

You can call the Add and Remove methods to insert and delete DataRow objects from the DataRowCollection. You can also call the Find method to search for DataRow objects that contain specific values in primary key columns, and the Contains method to search character-based data for single words or phrases.

Example

The following examples demonstrate using the Rows property to print the values of each column in each row of a table.

Private void RowsDemo ( DataTable myTable ) {

   foreach ( DataRow myRow in myTable.Rows ) {
      foreach ( DataColumn myCol in myTable.Columns ) {
         Response.Write ( myRow [ myCol ] );
      }
    }
}
  C# VB

Retrieving OleDb Data into a DataSet
Run Sample | View Source
Retrieving SQL Data into a DataSet
Run Sample | View Source
Retrieving XML Data into a DataSet
Run Sample | View Source

See Also

DataColumnCollection   DataRow   DataTable   Rows 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