Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Item Property (String, DataRowVersion)

DataRow.Item Property (String, DataRowVersion)

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

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

'Declaration
Public ReadOnly Property Item ( _
	columnName As String, _
	version As DataRowVersion _
) As Object

Parameters

columnName
Type: System.String

The name of the column.

version
Type: System.Data.DataRowVersion

One of the DataRowVersion values that specifies the row version that you want. Possible values are Default, Original, Current, and Proposed.

Property Value

Type: System.Object
An Object that contains the data.

ExceptionCondition
ArgumentException

The column specified by columnName cannot be found.

InvalidCastException

The data types of the value and the column do not match.

VersionNotFoundException

The row does not have this version of data.

DeletedRowInaccessibleException

The row was deleted.

The version should not be confused with the RowState property. The version argument describes the state of the data that is contained by the column relative to the column's original value. The RowState property describes the state of the whole row relative to its parent DataTable.

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 example gets the current version of data at a clicked cell of a DataGrid control.

Private Sub DataGrid1_Click _
    (ByVal sender As System.Object, ByVal e As System.EventArgs)

    ' Set the current row using the RowNumber property  
    ' of the CurrentCell. 
    Dim currentRow As DataRow = _
        CType(DataGrid1.DataSource, DataTable). _
        Rows(DataGrid1.CurrentCell.RowNumber)

    ' Print the current value of the column named "FirstName."
    Console.WriteLine(currentRow("FirstName", _
        DataRowVersion.Current).ToString())
End Sub

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show:
© 2015 Microsoft