asp.net.ph

DataTableCollection.Item Property ( Integer )

System.Data Namespace   DataTableCollection Class


Returns the DataTable at the specified index.

Syntax


DataTable variable = DataTableCollection.Item [ index ];
... or ...
DataTable variable = DataTableCollection [ index ];
  C# VB JScript

Parameters

index
The index of the DataTable to find.

Property Value

A DataTable at the specified index.

Exceptions


Exception Type Condition
IndexOutOfRangeException Occurs when the index value is greater than the number of items in the collection.

Remarks

Use the Contains method to determine if a table with a specific name exists. If you have the name of a table, but not its index, use the IndexOf method to return the index.

Example

The following example retrieves a DataTable by its index.

private void GetDataTableByIndex ( DataSet ds ) {
   // get the DataTableCollection.
   DataTableCollection myTables = ds.Tables;

   // iterate through the collection to get each table index.
   for ( int i = 0; i < myTables.Count; i++ ) {
      Response.Write ( myTables [ ].TableName );
   }
}
  C# VB

See Also

DataTableCollection Members   DataTableCollection.Item Overload List Skip Navigation Links


Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note