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 屬性。

適用於