Export (0) Print
Expand All

DataRowExtensions.SetField(Of T) Method (DataRow, DataColumn, T)

Sets a new value for the specified column in the DataRow. The SetField method also supports nullable types.

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

'Declaration
<ExtensionAttribute> _
Public Shared Sub SetField(Of T) ( _
	row As DataRow, _
	column As DataColumn, _
	value As T _
)

Type Parameters

T

A generic parameter that specifies the value type of the column.

Parameters

row
Type: System.Data.DataRow

The input DataRow, which acts as the this instance for the extension method.

column
Type: System.Data.DataColumn

The input DataColumn specifies which row value to retrieve.

value
Type: T

The new row value for the specified column, of type T.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DataRow. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

ExceptionCondition
ArgumentException

The column specified by column cannot be found.

ArgumentNullException

The column is null.

DeletedRowInaccessibleException

Occurs when attempting to set a value on a deleted row.

InvalidCastException

The value type of the underlying column could not be cast to the type specified by the generic parameter, T.

If value is null, the SetField method converts the null value to Value in the underlying DataColumn.

The SetField method does not perform any type conversions. This does not mean, however, that a type conversion will not occur. The SetField method exposes the ADO.NET 2.0 behavior of the DataRow class. A type conversion could be performed by the DataRow object and the converted value would then be saved to the row.

Exceptions can be passed up through the SetField method from the underlying DataRow object.

.NET Framework

Supported in: 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft