Documentation for this section has not yet been entered.
Use the ButtonField.DataTextFormatString property to specify a custom display format for the values that are displayed in the System.Web.UI.WebControls.ButtonField object. If the ButtonField.DataTextFormatString property is not set, the value for the field is displayed without any special formatting.
The format string is applied only when the ButtonField.DataTextField property is set.
The format string can be any literal string and usually includes a placeholder for the value for the field. For example, in the format string "Item Value: {0}", the {0} placeholder is replaced with the value for the field when it is displayed in the System.Web.UI.WebControls.ButtonField object. The rest of the format string is displayed as literal text.
If the format string does not include a placeholder, the value for the field from the data source is not included in the final display text.
The placeholder consists of two parts, separated by a colon and wrapped in braces, in the form { A : Bxx }. The value before the colon (A in the general example) specifies the index for the field value in a zero-based list of parameters.
This A parameter is part of the formatting syntax. Because there is only one field value in each cell, this value can only be set to 0.
The colon and the values after the colon are optional. The character after the colon (B in the general example) specifies the format in which to display the value. The following table lists the common formats.
C |
Displays numeric values in currency format. |
D |
Displays numeric values in decimal format. |
E |
Displays numeric values in scientific (exponential) format. |
F |
Displays numeric values in fixed format. |
G |
Displays numeric values in general format. |
N |
Displays numeric values in number format. |
X |
Displays numeric values in hexadecimal format. |
Except for X, the format characters are not case sensitive. The X format character displays the hexadecimal characters in the case that is specified.
The value after the format character (xx in the general example) specifies the number of significant digits or decimal places to display. For example, the format string "{0:F2}" displays a fixed-point number with two decimal places.
For more information on formatting strings, see Formatting Overview.
The value of this property is stored in view state.