| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
BoundField.DataFormatString PropertySystem.Web.UI.WebControls Namespace BoundField Class .NET Framework version 2.0 Sets or retrieves the string that specifies the display format of data for a BoundField. Syntax
Property Value
The property is read/write with no default value. RemarksUse the DataFormatString property to specify a custom display format for data in a BoundField control. By default, the formatting string is applied to the field value only when the parent control that contains the BoundField is in read-only mode. To apply the formatting string to field values while in edit mode, set the ApplyFormatInEditMode property to true. The data format string consists of two parts, separated by a colon and wrapped in braces, in the form { A:Bxx }
A specifies the parameter index in a zero-based list of parameters. This value can only be "0" since there is only one value in each cell. B specifies the format to display the value according to the following table:
The formatting character is not case sensitive except for "X", which displays the hexidecimal characters in the case specified. xx specifies the number of significant digits or decimal places to display the value. For example, the formatting string {0:D2} would format the cell to display a number with two decimal places.
For more information on formatting strings, see Formatting Base Types. ExampleThe following example demonstrates how to use the DataFormatString property to specify currency format for the column that displays prices in a GridView control. <asp:boundfield headertext = "Price"
datafield = "Price"
htmlencode=false
dataformatstring = "{0:c}"
itemstyle-horizontalalign = "right" />
The following table contains examples of formatting strings and the results. The example assumes standard English settings.
See Also |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme