Редагувати

Поділитися через


DataRowExtensions.SetField Method

Definition

Sets a new value for the specified column in the DataRow.

Overloads

SetField<T>(DataRow, DataColumn, T)

Sets a new value for the specified column in the DataRow. The SetField<T>(DataRow, DataColumn, T) method also supports nullable types.

SetField<T>(DataRow, Int32, T)

Sets a new value for the specified column in the DataRow the method is called on. The SetField<T>(DataRow, Int32, T) method also supports nullable types.

SetField<T>(DataRow, String, T)

Sets a new value for the specified column in the DataRow. The SetField<T>(DataRow, String, T) method also supports nullable types.

SetField<T>(DataRow, DataColumn, T)

Source:
DataRowExtensions.cs
Source:
DataRowExtensions.cs
Source:
DataRowExtensions.cs

Sets a new value for the specified column in the DataRow. The SetField<T>(DataRow, DataColumn, T) method also supports nullable types.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static void SetField(System::Data::DataRow ^ row, System::Data::DataColumn ^ column, T value);
public static void SetField<T> (this System.Data.DataRow row, System.Data.DataColumn column, T? value);
public static void SetField<T> (this System.Data.DataRow row, System.Data.DataColumn column, T value);
static member SetField : System.Data.DataRow * System.Data.DataColumn * 'T -> unit
<Extension()>
Public 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
DataRow

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

column
DataColumn

The input DataColumn specifies which row value to retrieve.

value
T

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

Exceptions

The column specified by column cannot be found.

The column is null.

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

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

Remarks

If value is null, the SetField method converts the null value to DBNull.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.

Applies to

SetField<T>(DataRow, Int32, T)

Source:
DataRowExtensions.cs
Source:
DataRowExtensions.cs
Source:
DataRowExtensions.cs

Sets a new value for the specified column in the DataRow the method is called on. The SetField<T>(DataRow, Int32, T) method also supports nullable types.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static void SetField(System::Data::DataRow ^ row, int columnIndex, T value);
public static void SetField<T> (this System.Data.DataRow row, int columnIndex, T? value);
public static void SetField<T> (this System.Data.DataRow row, int columnIndex, T value);
static member SetField : System.Data.DataRow * int * 'T -> unit
<Extension()>
Public Sub SetField(Of T) (row As DataRow, columnIndex As Integer, value As T)

Type Parameters

T

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

Parameters

row
DataRow

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

columnIndex
Int32

The zero-based ordinal of the column to set the value of.

value
T

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

Exceptions

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

The ordinal argument is out of range.

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

Remarks

If value is null, the SetField method converts the null value to DBNull.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.

Applies to

SetField<T>(DataRow, String, T)

Source:
DataRowExtensions.cs
Source:
DataRowExtensions.cs
Source:
DataRowExtensions.cs

Sets a new value for the specified column in the DataRow. The SetField<T>(DataRow, String, T) method also supports nullable types.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static void SetField(System::Data::DataRow ^ row, System::String ^ columnName, T value);
public static void SetField<T> (this System.Data.DataRow row, string columnName, T? value);
public static void SetField<T> (this System.Data.DataRow row, string columnName, T value);
static member SetField : System.Data.DataRow * string * 'T -> unit
<Extension()>
Public Sub SetField(Of T) (row As DataRow, columnName As String, value As T)

Type Parameters

T

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

Parameters

row
DataRow

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

columnName
String

The name of the column to set the value of.

value
T

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

Exceptions

The column specified by columnName cannot be found.

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

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

Remarks

If value is null, the SetField method converts the null value to DBNull.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.

Applies to