Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DataRow.ItemArray Property

Gets or sets all the values for this row through an array.

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

public Object[] ItemArray { get; set; }
/** @property */
public Object[] get_ItemArray ()

/** @property */
public void set_ItemArray (Object[] value)

public function get ItemArray () : Object[]

public function set ItemArray (value : Object[])

Not applicable.

Property Value

An array of type Object.

Exception typeCondition


The array is larger than the number of columns in the table.


A value in the array does not match its DataType in its respective DataColumn.


An edit broke a constraint.


An edit tried to change the value of a read-only column.


An edit tried to put a null value in a column where AllowDBNull of the DataColumn object is false.


The row has been deleted.

You can use this property to set or get values for this row through an array. If you use this property to set values, the array must have the same size and ordering as the column collection. Passing a null reference (Nothing in Visual Basic) in the ItemArray indicates that no value was specified.

Users can generate exceptions in the ColumnChanging event or the RowChanging event.

The following examples show how to get and set values using the ItemArray property.

private void CreateRowsWithItemArray()
    // Make a DataTable using the function below.
    DataTable dt = MakeTableWithAutoIncrement();
    DataRow relation;
    // Declare the array variable.
    object [] rowArray = new object[2];
    // Create 10 new rows and add to DataRowCollection.
    for(int i = 0; i <10; i++)
        rowArray[1]= "item " + i;
        relation = dt.NewRow();
        relation.ItemArray = rowArray;
private DataTable MakeTableWithAutoIncrement()
    // Make a table with one AutoIncrement column.
    DataTable table = new DataTable("table");
    DataColumn idColumn = new DataColumn("id", 
    idColumn.AutoIncrement = true;
    idColumn.AutoIncrementSeed = 10;

    DataColumn firstNameColumn = new DataColumn("Item", 
    return table;
private void PrintTable(DataTable table)
    foreach(DataRow row in table.Rows)
        foreach(DataColumn column in table.Columns)

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

© 2015 Microsoft