asp.net.ph

DataColumnCollection Class

System.Data Namespace


Represents a collection of columns for a DataTable.

DataColumnCollection Class Members

Collapse   Properties

Visibility Name Value Type Accessibility
public Item ( String name ) DataColumn [ Get ]
public Item ( Int32 index ) DataColumn [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public Add ( String columnName , Type type ) DataColumn
public Add ( String columnName ) DataColumn
public Add ( ) DataColumn
public Add ( DataColumn column ) Void
public Add ( String columnName , Type type , String expression ) DataColumn
public AddRange ( DataColumn columns ) Void
public CanRemove ( DataColumn column ) Boolean
public Clear ( ) Void
public Contains ( String name ) Boolean
public CopyTo ( DataColumn array , Int32 index ) Void
public IndexOf ( String columnName ) Int32
public IndexOf ( DataColumn column ) Int32
public Remove ( String name ) Void
public Remove ( DataColumn column ) Void
public RemoveAt ( Int32 index ) Void

Collapse   Events

Multicast Name Type
multicast CollectionChanged CollectionChangeEventHandler

Remarks

The DataColumnCollection defines the schema of a DataTable, and determines what kind of data each DataColumn can contain. This collection is accessed via the DataTable.Columns property.

Like most data collections in ADO.NET, the DataColumnCollection uses standard collection methods to manage the items in the collection. These include the methods Add, Clear, and Remove.

The collection also includes a Count property to determine how many DataColumn objects are in the collection, and a Contains method to verify whether a specified column index or name exists in the collection.

Example

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

Private void ColumnsDemo ( 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

Columns   DataColumn   DataTable   DataRelation   DataRow   DataSet 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