asp.net.ph

DataTableCollection.IndexOf Method ( String )

System.Data Namespace   DataTableCollection Class


Returns the index of a DataTable with the specified name.

[ VB ]
Overloads Overridable Public Function IndexOf ( _
   ByVal tableName As String _
) As Integer

[ C# ]
public virtual int IndexOf (
   String tableName
);

[ C++ ]
public: virtual int IndexOf (
   String* tableName
);

[ JScript ]
public function IndexOf (
   tableName : String
) : int

Parameters

tableName
The name of 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 a named table in a DataTableCollection.

private void GetIndexes ( DataSet ds ) {
   DataTableCollection myTables = ds.Tables;
   // get the index of the table named "Authors", if it exists.
   if ( myTables.Contains ( "Authors" ) ) {
      Response.Write ( myTables.IndexOf ( "Authors" ) );
   }
}
  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