Gets the data stored at the column; the column is specified by passing a DataColumn to the property. Additionally, you can specify which version of the data to retrieve.
[C#] In C#, this member is the indexer for the DataRow class.
[Visual Basic] Overloads Public Default ReadOnly Property Item( _ ByVal column As DataColumn, _ ByVal version As DataRowVersion _ ) As Object [C#] public object this[ DataColumn column, DataRowVersion version ] {get;} [C++] public: __property Object* get_Item( DataColumn* column, DataRowVersion version ); [JScript] returnValue = DataRowObject.Item(column, version); -or- returnValue = DataRowObject(column, version);
[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed Item property whose type is Object and whose index type is String.
An Object that contains the data.
Exception Type | Condition |
---|---|
ArgumentNullException | The column argument contains null. |
ArgumentException | The column doesn't belong to the table. |
VersionNotFoundException | The row doesn't have this version of data. |
The version shouldn't be confused with the RowState property. The version argument describes the state of the data contained by the column in relation to the column's original value.
When setting the property, an exception will be thrown if an exception occurs in the ColumnChanging event.
If this is an immediate edit, see EndEdit for the exceptions that can be thrown.
The following example gets the current value of a clicked cell in the System.WinForms.DataGrid control.
[Visual Basic]
Private Sub DataGrid1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim currRow As DataRow Dim c As DataColumn ' Set the current row using the RowNumber property of the CurrentCell. currRow = DataGrid1.DataGridTable.DataTable. _ Rows(DataGrid1.CurrentCell.RowNumber) c = DataGrid1.DataGridTable.DataTable.Columns(1) ' Get the value of the column 1 in the DataTable. label1.Text = CurrRow(c, DataRowVersion.Current) End Sub
DataRow Class | DataRow Members | System.Data Namespace | DataRow.Item Overload List | DataRowVersion