DisplayFormatAttribute.ConvertEmptyStringToNull 属性

定义

获取或设置一个值,该值指示在数据源中更新数据字段时是否将空字符串值 ("") 自动转换为 null

public:
 property bool ConvertEmptyStringToNull { bool get(); void set(bool value); };
public bool ConvertEmptyStringToNull { get; set; }
member this.ConvertEmptyStringToNull : bool with get, set
Public Property ConvertEmptyStringToNull As Boolean

属性值

如果将空字符串值自动转换为 true,则为 null;否则为 false。 默认值为 true

示例

以下示例演示如何使用 ConvertEmptyStringToNull 启用空字符串值到 null的转换。

// Display the text [Null] when the data field is empty.
// Also, convert empty string to null for storing.
[DisplayFormat(ConvertEmptyStringToNull = true, NullDisplayText = "[Null]")]
public object Size;
' Display the text [Null] when the data field is empty.
' Also, convert empty string to null for storing.
<DisplayFormat(ConvertEmptyStringToNull:=True, NullDisplayText:="[Null]")> _
Public Size As Object

注解

用户可能会为字段值输入空字符串。 ConvertEmptyStringToNull使用 属性指定在数据库中更新数据字段时是否自动将空字符串值转换为 null

注意

默认情况下, DynamicField 对象将值显示为 null 空字符串。 若要显示其他值,请设置 NullDisplayText 属性。

适用于