DataTableCollection.IndexOf Method (DataTable)
.NET Framework 2.0
Gets the index of the specified DataTable object.
Namespace: System.Data
Assembly: System.Data (in system.data.dll)
Assembly: System.Data (in system.data.dll)
Use the IndexOf method to determine the exact index of a given table.
Before calling IndexOf, you can test for the existence of a table (specified by either index or name) by using the Contains method.
The following example returns the index of each table in the DataTableCollection.
private void GetIndexes() { // Get the DataSet of a DataGrid. DataSet thisDataSet = (DataSet)DataGrid1.DataSource; // Get the DataTableCollection through the Tables property. DataTableCollection tables = thisDataSet.Tables; // Get the index of each table in the collection. foreach (DataTable table in tables) System.Diagnostics.Debug.WriteLine(tables.IndexOf(table));
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.