通过


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

属性值

如果自动转换为 空字符串值,则为 ;否则为 < a1/ >。 默认值为 true

示例

下面的示例演示如何使用 /> 将空字符串值 转换为 。

// 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 属性。

适用于