DisplayFormatAttribute.DataFormatString Property
Gets or sets the display format for the field value.
Namespace: System.ComponentModel.DataAnnotations
Assembly: System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)
Property Value
Type: System.StringA formatting string that specifies the display format for the value of the data field. The default is an empty string (""), which indicates that no special formatting is applied to the field value.
Use the DataFormatString property to specify a custom display format for the values that are displayed in the DynamicField object. If the DataFormatString property is not set, the field's value is displayed without any special formatting. For more information, see Formatting Types.
Note |
|---|
When the DynamicField.HtmlEncode property is true, the value of the field is HTML encoded to its string representation before the formatting string is applied. For some objects, such as dates, you might want to control how the object is displayed with a formatting string. In those cases, you must set the DynamicField.HtmlEncode property to false. |
By default, the formatting string is applied to the field value only when the data-bound control that contains the DynamicField object is in read-only mode. To apply the formatting string to field values when they are in edit mode, set the ApplyFormatInEditMode property to true.
The formatting string can be any literal string and usually includes a placeholder for the field's value. For example, in the formatting string "Item Value: {0}", the field's value is substituted for the {0} placeholder when the string is displayed in the DynamicField object. The remainder of the formatting string is displayed as literal text.
Note |
|---|
If the formatting string does not include a placeholder, the field's value from the data source is not included in the final display text. |
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note