asp.net.ph

DataRow.Item Property ( Int32, DataRowVersion )

System.Data Namespace   DataRow Class


Returns the specified version of data in the given column index.

Syntax


Object variable = DataRow.Item [ columnIndex, version ];
... or ...
Object variable = DataRow [ columnIndex, version ];
  C# VB JScript

Parameters

columnIndex
The zero-based index of the column.
version
One of the DataRowVersion values that specifies the desired row version. Possible values are Default, Original, Current, and Proposed.

Property Value

An Object that contains the data.

Exceptions


Exception Type Condition
VersionNotFoundException Occurs when the row does not have this version of data.
IndexOutOfRangeException Occurs when the columnIndex argument is out of range.
InvalidCastException Occurs when the data types of the value and the column do not match.
DeletedRowInaccessibleException Occurs when an attempt was made to set a value on a deleted row.

Remarks

You can only create or update a row after calling the BeginEdit method; similarly, the EndEdit method must be called to commit the edit. After calling the EndEdit method, and before calling the AcceptChanges method, internal representations of the original and new proposed values are stored. Therefore, until you call the AcceptChanges, you can use the version argument to specify which version of a column's value you need, either the DataRowVersion.Original or DataRowVersion.Proposed. Once you call the AcceptChanges method, however, the version of the column reverts to DataRowVersion.Original. If the row is new, you can also pass DataRowVersion.Default for the parameter to retrieve the column's default value. When passing DataRowVersion.Current, the property will return the current value, whatever its version may be.

NOTE: the BeginEdit method is called implicitly when you change the value of a databound control or when a DataRow object is added to the DataRowCollection; the EndEdit method is called implicitly when calling the following methods: the DataRow object's AcceptChanges method, the DataTable object's AcceptChanges method, or the CancelEdit method.

By contrast, the DataRowVersion enumeration Current returns the version of the data after the EndEdit method has been called.

The version argument 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. The RowState property describes the state of the entire row in relation to its parent DataTable.

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.

See Also

DataRow Members   DataRow.Item Overload List Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph