DataRow.Item Property (DataColumn, DataRowVersion)

 

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

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

Public ReadOnly Property Item (
	column As DataColumn,
	version As DataRowVersion
) As Object

Parameters

column
Type: System.Data.DataColumn

A DataColumn that contains information about 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.

Exception Condition
ArgumentException

The column does not belong to the table.

ArgumentNullException

The column argument contains null.

VersionNotFoundException

The row does not have this version of data.

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.

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 value of a clicked cell in the DataGrid control.

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

    Dim dataGridTable As DataTable = _
        CType(DataGrid1.DataSource, DataTable)

    ' Set the current row using the RowNumber 
    ' property of the CurrentCell.
    Dim currentRow As DataRow = dataGridTable.Rows( _
        DataGrid1.CurrentRowIndex)
    Dim column As DataColumn = dataGridTable.Columns(1)

    ' Get the value of the column 1 in the DataTable.
    label1.Text = currentRow(column, _
        DataRowVersion.Current).ToString()
End Sub

.NET Framework
Available since 1.1
Return to top
Show: