asp.net.ph

DataTableCollection.IndexOf Method ( DataTable )

System.Data Namespace   DataTableCollection Class


Returns the index of a specified DataTable object.

[ VB ]
Overloads Overridable Public Function IndexOf ( _
   ByVal table As DataTable _
) As Integer

[ C# ]
public virtual int IndexOf (
   DataTable table
);

[ C++ ]
public: virtual int IndexOf (
   DataTable* table
);

[ JScript ]
public function IndexOf (
   table : DataTable
) : int;

Parameters

table
The DataTable to find.

Return Value

The index of the DataTable if it is in the collection; otherwise, -1.

Remarks

Use the IndexOf method to determine the index of a given table.

Before calling IndexOf, you can test for the existence of a table by using the Contains method.

Example

The following example returns the index of each table in a DataTableCollection.

private void GetIndexes ( DataSet ds ) {
   DataTableCollection myTables = ds.Tables;

   // get the index of each table in the collection.
   foreach ( DataTable tbl in myTables ) {
      Response.Write ( myTables.IndexOf ( tbl ) );
   }
}
  C# VB

See Also

DataTableCollection Members   DataTableCollection.IndexOf Overload List   Contains 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