DisplayFormatAttribute.ConvertEmptyStringToNull 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定一個值,指示資料欄位更新時,空字串值(「」)是否會自動轉換成 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