asp.net.ph

ButtonColumn.DataTextFormatString Property

System.Web.UI.WebControls Namespace   ButtonColumn Class


Sets or retrieves the display format for the text caption of the buttons in the column.

Syntax


Inline <asp:buttoncolumn datatextformatstring = strFormat ... >
Script ButtonColumn.DataTextFormatString = strFormat

Property Value


strFormat String specifying the display format for the text caption of the buttons in the column.

The property is read/write with no default value.

Remarks

Use the DataTextFormatString property to provide a custom display format for the text caption of the buttons in the column. The specified format is only applied to the text caption when the text caption is data-bound to a field in a data source. Specify the field to bind to the text caption of the buttons in the column by setting the DataTextField property.

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:

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.

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.

NOTE: The entire string must be enclosed in curly brackets to denote that this is a format string and not a literal string. Any text outside of the curly brackets is displayed as literal text.

For more information on formatting strings, see Formatting Base Types.

Example

The following table contains examples of formatting strings and the results. The example assumes standard English settings.

Numeric Value Format String Result
12345.6789 "{0:C}" $12,345.68
-12345.6789 "{0:C}" ( $12,345.68 )
12345 "{0:D}" 12345
12345 "{0:D8}" 00012345
12345.6789 "{0:E}" 1234568E+004
12345.6789 "{0:E10}" 1.2345678900E+004
12345.6789 "{0:F}" 12345.68
12345.6789 "{0:F0}" 12346
12345.6789 "{0:G}" 12345.6789
123456789 "{0:G7}" 1.234568E8
12345.6789 "{0:N}" 12,345.68
123456789 "{0:N4}" 123,456,789.0000
12345.6789 "Total: {0:C}" Total: $12345.68

See Also

ButtonColumn Members   Adding Button Columns to a DataGrid Control Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 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 asp.net.ph