Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DataRowCollection.Item Property

Gets the row at the specified index.

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

public DataRow this [
	int index
] { get; 
/** @property */
public DataRow get_Item (int index)

JScript supports the use of indexed properties, but not the declaration of new ones.

Parameters

index

The zero-based index of the row to return.

Property Value

The specified DataRow.
Exception typeCondition

IndexOutOfRangeException

The index value is greater than the number of items in the collection.

Use the Contains method to determine whether a specific value exists in the key column of a row.

The following example prints the value of column 1 of each row in a DataRowCollection.

private void PrintRows(DataTable table)
{
    // Print the CompanyName column for every row using the index.
    for(int i = 0; i < table.Rows.Count; i++)
    {
        Console.WriteLine(table.Rows[i]["CompanyName"]);
    


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.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.