DisplayFormatAttribute.NullDisplayText Właściwość

Definicja

Pobiera lub ustawia tekst wyświetlany dla pola, gdy wartość pola to null.

public:
 property System::String ^ NullDisplayText { System::String ^ get(); void set(System::String ^ value); };
public string NullDisplayText { get; set; }
public string? NullDisplayText { get; set; }
member this.NullDisplayText : string with get, set
Public Property NullDisplayText As String

Wartość właściwości

Tekst wyświetlany dla pola, gdy wartość pola to null. Wartość domyślna to pusty ciąg (""), który wskazuje, że ta właściwość nie jest ustawiona.

Przykłady

W poniższym przykładzie pokazano, jak użyć elementu NullDisplayText , aby zdefiniować podpis do wyświetlenia, gdy pole danych ma wartość 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

Uwagi

Czasami wartość pola danych jest przechowywana jako wartości null w źródle. Możesz określić niestandardowy tekst do wyświetlenia dla pól danych, które mają wartość null, ustawiając NullDisplayText właściwość . Jeśli ta właściwość nie jest ustawiona, wartości pól null są wyświetlane jako puste ciągi ("").

Uwaga

Aby przekonwertować wartość pola pustego ciągu na wartość null, należy ustawić ConvertEmptyStringToNull właściwość na truewartość .

Dotyczy

Zobacz też