Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

DisplayFormatAttribute.ConvertEmptyStringToNull Property

Definition

Namespace:
System.ComponentModel.DataAnnotations
Assemblies:
System.ComponentModel.Annotations.dll, System.ComponentModel.DataAnnotations.dll
Assembly:
System.ComponentModel.Annotations.dll
Assembly:
System.ComponentModel.DataAnnotations.dll
Source:
DisplayFormatAttribute.cs
Source:
DisplayFormatAttribute.cs
Source:
DisplayFormatAttribute.cs
Source:
DisplayFormatAttribute.cs
Source:
DisplayFormatAttribute.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Gets or sets a value that indicates whether empty string values ("") are automatically converted to null when the data field is updated in the data source.

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

Property Value

true if empty string values are automatically converted to null; otherwise, false. The default is true.

Examples

The following example shows how to use the ConvertEmptyStringToNull to enable the conversion of empty string values to 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

Users might enter an empty string for a field value. Use the ConvertEmptyStringToNull property to specify whether an empty string value is automatically converted to null when the data field is updated in the database.

Note

By default, a DynamicField object displays null values as empty strings. To display a different value, set the NullDisplayText property.

Applies to


Feedback

Was this page helpful?