The DisplayField helper has two functions:
DetailForm associated with a DataGrid.
- It formats the data according to the information supplied by the [DisplayFormat] data annotation. The format specified there can be overriden by specifying a not
null value for the optional format parameter.
The DisplayFormat attribute has also two optional array arguments that are used to display values for
boolean and enumeration fields. The first arguments supplies a list of strings, while the second one a list of image urls. For each value of the
enumeration, bool? or bool it associate an integer with its actual value according to the following rules:
- For bool values true is associated with 1 and false
- For bool? values null is associated with 0, 1 with false and 2 with
- In case of enumerations the enumeration is converted into an
int32 by means of the Convert class.
Then it tries to find an image url at the index postion specified by the previously computed integer, if it fails back up on a string value. One can therefore mix both images and strings.
In case of bool values if neither of the two arrays is supplied the value is displayed by means of a disabled checkbox. In case of enumerations, instead, if neither of the two arrays supplies a value for an element the element is converted
into a string using the Convert class.