DataRowExtensions::SetField<T> Method (DataRow^, DataColumn^, T)
Sets a new value for the specified column in the DataRow. The SetField<T> method also supports nullable types.
Assembly: System.Data.DataSetExtensions (in System.Data.DataSetExtensions.dll)
public: generic<typename T> [ExtensionAttribute] static void SetField( DataRow^ row, DataColumn^ column, T value )
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.
Type Parameters
- T
A generic parameter that specifies the value type of the column.
| Exception | Condition |
|---|---|
| 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<T> method converts the null value to Value in the underlying DataColumn.
The SetField<T> method does not perform any type conversions. This does not mean, however, that a type conversion will not occur. The SetField<T> 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<T> method from the underlying DataRow object.
Available since 3.5