This documentation is archived and is not being maintained.

DataRow.Item Property

Gets or sets data stored in a specified column.

[C#] In C#, this property is the indexer for the DataRow class.

Overload List

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

[Visual Basic] Overloads Public Default Property Item(String) As Object
[C#] public object this[string] {get; set;}
[C++] public: __property Object* get_Item(String*);
public: __property void set_Item(String*, Object*);
[JScript] DataRow.Item (String)

Gets or sets the data stored in the specified DataColumn.

[Visual Basic] Overloads Public Default Property Item(DataColumn) As Object
[C#] public object this[DataColumn] {get; set;}
[C++] public: __property Object* get_Item(DataColumn*);
public: __property void set_Item(DataColumn*, Object*);
[JScript] DataRow.Item (DataColumn)

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

[Visual Basic] Overloads Public Default Property Item(Integer) As Object
[C#] public object this[int] {get; set;}
[C++] public: __property Object* get_Item(int);
public: __property void set_Item(int, Object*);
[JScript] DataRow.Item (int)

Gets the specified version of data stored in the specified DataColumn.

[Visual Basic] Overloads Public Default ReadOnly Property Item(DataColumn, DataRowVersion) As Object
[C#] public object this[DataColumn, DataRowVersion] {get;}
[C++] public: __property Object* get_Item(DataColumn*, DataRowVersion);
[JScript] DataRow.Item (DataColumn, DataRowVersion)

Gets the specified version of data stored in the named column.

[Visual Basic] Overloads Public Default ReadOnly Property Item(String, DataRowVersion) As Object
[C#] public object this[string, DataRowVersion] {get;}
[C++] public: __property Object* get_Item(String*, DataRowVersion);
[JScript] DataRow.Item (String, DataRowVersion)

Gets the data stored in the column, specified by index and version of the data to retrieve.

[Visual Basic] Overloads Public Default ReadOnly Property Item(Integer, DataRowVersion) As Object
[C#] public object this[int, DataRowVersion] {get;}
[C++] public: __property Object* get_Item(int, DataRowVersion);
[JScript] DataRow.Item (int, DataRowVersion)

Example

[Visual Basic] The following example gets the current value of a column through the DataRow object's Item property.

[Visual Basic] Note   This example shows how to use one of the overloaded versions of the Item property (DataRow indexer). For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Private Sub DataGrid1_Click _
(ByVal sender As System.Object, ByVal e As System.EventArgs)
   Dim currRow As DataRow
   ' Set the current row using the RowNumber property of the CurrentCell.
   currRow = CType(DataGrid1.DataSource, DataTable). _
      Rows(DataGrid1.CurrentCell.RowNumber)
   ' Get the value of the column 1 in the DataTable.
   label1.Text = currRow(1, DataRowVersion.Current).ToString()
End Sub

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

DataRow Class | DataRow Members | System.Data Namespace

Show: