Szerkesztés

Megosztás a következőn keresztül:


DisplayFormatAttribute.NullDisplayText Property

Definition

Gets or sets the text that is displayed for a field when the field's value is 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

Property Value

The text that is displayed for a field when the field's value is null. The default is an empty string (""), which indicates that this property is not set.

Examples

The following example shows how to use the NullDisplayText to define a caption to display when the data field is 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

Remarks

Sometimes a data field's value is stored as null values in the source. You can specify custom text to display for data fields that have a null value by setting the NullDisplayText property. If this property is not set, null field values are displayed as empty strings ("").

Note

To convert an empty string field value to a null value, you must set the ConvertEmptyStringToNull property to true.

Applies to

See also