Item Property (String)

DataRow.Item Property (String)

Gets or sets the data stored in the column specified by name.

Namespace: System.Data
Assembly: System.Data (in

public Object this [
	string columnName
] { get; set; }
/** @property */
public Object get_Item (String columnName)

/** @property */
public void set_Item (String columnName, Object value)

Not applicable.



The name of the column.

Property Value

An Object that contains the data.

Exception typeCondition


The column specified by columnName cannot be found.


Occurs when you try to set a value on a deleted row.


Occurs when you set a value and its Type does not match DataType.

When you set the property, an exception is generated if an exception occurs in the ColumnChanging event.

If this is an immediate edit, see EndEdit for the exceptions that can be generated.

The following examples demonstrate the use of the Item property to get and set the value of a specific column index. The first example gets the value of the first column in any row that a user clicks in a DataGrid control. The second sets a value passed as an argument to the method.

private void DataGrid1_Click(
    object sender, System.EventArgs e)
    // Get the DataTable the grid is bound to.
    DataGrid thisGrid = (DataGrid) sender;
    DataTable table = (DataTable) thisGrid.DataSource;
    DataRow currentRow = 

    // Get the value of the column 1 in the DataTable.
    // You can also use the index:
    // Console.WriteLine(currentRow[1]);
private void SetDataRowValue(
    DataGrid grid, object newValue)
    // Set the value of the first column in 
    // the last row of a DataGrid.
    DataTable table = (DataTable) grid.DataSource;
    DataRow row = table.Rows[table.Rows.Count-1];
    row["FirstName"] = newValue;

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