Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

ListControl::DataTextFormatString Property

Gets or sets the formatting string used to control how data bound to the list control is displayed.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
[ThemeableAttribute(false)]
public:
virtual property String^ DataTextFormatString {
	String^ get ();
	void set (String^ value);
}
<asp:ListControl DataTextFormatString="String" />

Property Value

Type: System::String
The formatting string for data bound to the control. The default value is String::Empty.

Use the DataTextFormatString property to provide a custom display format the items in a list control.

The data format string consists of two parts, separated by a colon, in the form { A : Bxx }. For example, the formatting string {0:F2} would format the cell to display a fixed point number with two decimal places.

NoteNote

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.

NoteNote

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.

NoteNote

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.

The following table contains examples of formatting strings and the results. It 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

For more information on formatting strings, see Formatting Types.

The value of this property is stored in view state.

This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.