BoundColumn.DataFormatString Property
Assembly: System.Web (in system.web.dll)
public: virtual property String^ DataFormatString { String^ get (); void set (String^ value); }
/** @property */ public String get_DataFormatString () /** @property */ public void set_DataFormatString (String value)
public function get DataFormatString () : String public function set DataFormatString (value : String)
Not applicable.
Property Value
A formatting string that specifies the display format of items in the column. The default value is String.Empty.Use the DataFormatString property to provide a custom format for the items in the column.
The data format string consists of two parts, separated by a colon, in the form { A : Bxx }. For example, the formatting string {0:F2} displays a fixed-point number with two decimal places.
Note: |
|---|
| The entire string must be enclosed in braces to indicate that it is a format string and not a literal string. Any text outside the braces is displayed as literal text. |
The value before the colon (A in the general example) specifies the parameter index in a zero-based list of parameters.
Note: |
|---|
| This value can only be set to 0 because there is only one value in each cell. |
The character after the colon (B in the general example) specifies the format to display the value in. The following table lists the common formats.
| Format character | Description |
|---|---|
| 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. |
Note: |
|---|
| The format character is not case-sensitive, except for X, which displays the hexadecimal characters in the case specified. |
The value after the format character (xx in the general example) specifies the number of significant digits or decimal places to display.
For more information on formatting strings, see Formatting Overview.
The following example demonstrates how to use the DataFormatString property to specify various formats for the columns in the DataGrid control. The Qty column is formatted as an integer, the Price column is formatted as currency, the Weight column is formatted as a decimal number, and the Expires column is formatted as a short date and time string.
Note: