DataRowExtensions.SetField Method

Definition

DataRow 中的指定列设置一个新值。Sets a new value for the specified column in the DataRow.

Overloads

SetField<T>(DataRow, DataColumn, T)

DataRow 中的指定列设置一个新值。Sets a new value for the specified column in the DataRow. SetField<T>(DataRow, DataColumn, T) 方法还支持可以为 null 的类型。The SetField<T>(DataRow, DataColumn, T) method also supports nullable types.

SetField<T>(DataRow, Int32, T)

为在其上调用此方法的 DataRow 中的指定列设置一个新值。Sets a new value for the specified column in the DataRow the method is called on. SetField<T>(DataRow, Int32, T) 方法还支持可以为 null 的类型。The SetField<T>(DataRow, Int32, T) method also supports nullable types.

SetField<T>(DataRow, String, T)

DataRow 中的指定列设置一个新值。Sets a new value for the specified column in the DataRow. SetField<T>(DataRow, String, T) 方法还支持可以为 null 的类型。The SetField<T>(DataRow, String, T) method also supports nullable types.

SetField<T>(DataRow, DataColumn, T)

DataRow 中的指定列设置一个新值。Sets a new value for the specified column in the DataRow. SetField<T>(DataRow, DataColumn, T) 方法还支持可以为 null 的类型。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);
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

输入的 DataRow,充当扩展方法的 this 实例。The input DataRow, which acts as the this instance for the extension method.

column
DataColumn

输入 DataColumn 指定要检索的行值。The input DataColumn specifies which row value to retrieve.

value
T

指定列的新行值,类型为 TThe new row value for the specified column, of type T.

Exceptions

找不到由 column 指定的列。The column specified by column cannot be found.

column 为“null”。The column is null.

尝试对已删除的行设置值时发生。Occurs when attempting to set a value on a deleted row.

基础列的值类型无法转换为泛型参数 T 指定的类型。The value type of the underlying column could not be cast to the type specified by the generic parameter, T.

Remarks

如果 valuenull,则 SetField 方法会将null值转换为基础 DataColumn中的 ValueIf value is null, the SetField method converts the null value to Value in the underlying DataColumn.

SetField 方法不执行任何类型转换。The SetField method does not perform any type conversions. 但这并不意味着不会发生类型转换。This does not mean, however, that a type conversion will not occur. SetField 方法公开 ADO.NET 2.0ADO.NET 2.0 类的 DataRow 行为。The SetField method exposes the ADO.NET 2.0ADO.NET 2.0 behavior of the DataRow class. 类型转换可以由 DataRow 对象执行,转换后的值随后将保存到该行。A type conversion could be performed by the DataRow object and the converted value would then be saved to the row.

可以通过基础 DataRow 对象中的 SetField 方法向上传递异常。Exceptions can be passed up through the SetField method from the underlying DataRow object.

SetField<T>(DataRow, Int32, T)

为在其上调用此方法的 DataRow 中的指定列设置一个新值。Sets a new value for the specified column in the DataRow the method is called on. SetField<T>(DataRow, Int32, T) 方法还支持可以为 null 的类型。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);
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

输入的 DataRow,充当扩展方法的 this 实例。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

指定列的新行值,类型为 TThe new row value for the specified column, of type T.

Exceptions

尝试对已删除的行设置值时发生。Occurs when attempting to set a value on a deleted row.

ordinal 参数超出范围。The ordinal argument is out of range.

基础列的值类型无法转换为泛型参数 T 指定的类型。The value type of the underlying column could be not cast to the type specified by the generic parameter, T.

Remarks

如果 valuenull,则 SetField 方法会将null值转换为基础 DataColumn中的 ValueIf value is null, the SetField method converts the null value to Value in the underlying DataColumn.

SetField 方法不执行任何类型转换。The SetField method does not perform any type conversions. 但这并不意味着不会发生类型转换。This does not mean, however, that a type conversion will not occur. SetField 方法公开 ADO.NET 2.0ADO.NET 2.0 类的 DataRow 行为。The SetField method exposes the ADO.NET 2.0ADO.NET 2.0 behavior of the DataRow class. 类型转换可以由 DataRow 对象执行,转换后的值随后将保存到该行。A type conversion could be performed by the DataRow object and the converted value would then be saved to the row.

可以通过基础 DataRow 对象中的 SetField 方法向上传递异常。Exceptions can be passed up through the SetField method from the underlying DataRow object.

SetField<T>(DataRow, String, T)

DataRow 中的指定列设置一个新值。Sets a new value for the specified column in the DataRow. SetField<T>(DataRow, String, T) 方法还支持可以为 null 的类型。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);
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

输入的 DataRow,充当扩展方法的 this 实例。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

指定列的新行值,类型为 TThe new row value for the specified column, of type T.

Exceptions

找不到由 columnName 指定的列。The column specified by columnName cannot be found.

尝试对已删除的行设置值时发生。Occurs when attempting to set a value on a deleted row.

基础列的值类型无法转换为泛型参数 T 指定的类型。The value type of the underlying column could not be cast to the type specified by the generic parameter, T.

Remarks

如果 valuenull,则 SetField 方法会将null值转换为基础 DataColumn中的 ValueIf value is null, the SetField method converts the null value to Value in the underlying DataColumn.

SetField 方法不执行任何类型转换。The SetField method does not perform any type conversions. 但这并不意味着不会发生类型转换。This does not mean, however, that a type conversion will not occur. SetField 方法公开 ADO.NET 2.0ADO.NET 2.0 类的 DataRow 行为。The SetField method exposes the ADO.NET 2.0ADO.NET 2.0 behavior of the DataRow class. 类型转换可以由 DataRow 对象执行,转换后的值随后将保存到该行。A type conversion could be performed by the DataRow object and the converted value would then be saved to the row.

可以通过基础 DataRow 对象中的 SetField 方法向上传递异常。Exceptions can be passed up through the SetField method from the underlying DataRow object.

Applies to