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

適用対象