System.Data Namespace DataColumnCollection Class
Returns the specified DataColumn from the collection.
1. Returns the DataColumn at the specified index in the collection.
2. Returns the DataColumn from the collection with the specified name.
The following example uses the Item property to print the DataType value of a DataColumn object specified by name.
NOTE: This example shows how to use one of the overloaded versions of the Item property ( DataColumnCollection indexer ). For other examples that may be available, see the individual overload topics.
private void PrintDataType ( DataTable dt ) {
// get the DataColumnCollection from a DataTable in a DataSet.
DataColumnCollection cols = dt.Columns;
// print the column's data type.
Response.Write ( cols [ "Totals" ].DataType );
}
DataColumnCollection Members