Re: How to use formatting expression on DataGrid bound column.

Joined
Jul 30, 2006
Messages
2
Reaction score
0
I used the following formatting expression for dates and it seemed to work: {0:MM/dd/yyyy}
 
Joined
Jul 30, 2006
Messages
2
Reaction score
0
Go to this web site for more information, such as that below: http://msdn2.microsoft.com/en-us/library/c76820yk.aspx.

Data formatting expression
A .NET Framework formatting expression that is applied to the data before it is displayed in the column. The expression consists of optional static text and a format specifier that takes the following form:
{0:format specifier}
The number in front of the colon :)) is a parameter index that indicates which data elements in the column to format; it is therefore usually zero to indicate the first (and only) element. The format specifier follows the colon and consists of one or more letters that indicate how to format the data. The format-specifier characters you can use depend on what type of data you are formatting — dates, numbers, or other types. The following table shows examples of formatting expressions for different types of data. For more information about formatting expressions, see Formatting Types.

Format expression Applied to this data type Description
Price: {0:C} numeric/decimal Displays the literal string "Price:" followed by numbers in currency format. The currency format depends on the culture setting specified through the culture attribute on the @ Page directive or in the Web.config file.
{0:D4} integer (Cannot be used with decimal numbers.) Integers are displayed in a zero-padded field four characters wide.
{0:N2}% numeric Displays the number with 2-decimal-place precision, followed by the literal string "%".
{0:000.0} numeric/decimal Numbers rounded to one decimal place. Numbers less than three digits are zero-padded.
{0:D} date/datetime Long date format ("Thursday, August 06, 1996"). Date format depends on the culture setting of the page or the Web.config file.
{0:d} date/datetime Short date format ("12/31/99").
{0:yy-MM-dd} date/datetime Date in numeric year-month-day format (96-08-06).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top