Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: How to use formatting expression on DataGrid bound column.

Reply
Thread Tools

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

 
 
Sonali.NET[MVP]
Guest
Posts: n/a
 
      06-25-2003
Refer
http://www.c-sharpcorner.com/Code/20...taGridData.asp
http://www.c-sharpcorner.com/Code/20...rmatString.asp

HTH
Regards
Sushila
..NET MVP

"Manu" <> wrote in message news:0c8a01c33a96$dac16a40$...
> When Creating a DataGrid it possible format every item
> using the DataGrid Property builder.
> In the builder under Bound column we will find data
> formatting expression field which according to MS help
> should contain an expression that will be applied on the
> column's data before presenting it. For example it is
> written that transforming Date/time format to a short
> presentation should be done here. It was not written HOW
> to write these formatting expressions.
>
> I would like to show a field of type Date/Time in it's
> short version (only dd/mm/yyyy) in a DataGrid. What
> expression should I use in the data formatting expression
> field?
>


 
Reply With Quote
 
 
 
 
TimDay TimDay is offline
Junior Member
Join Date: Jul 2006
Location: Atlanta
Posts: 2
 
      07-30-2006
I used the following formatting expression for dates and it seemed to work: {0:MM/dd/yyyy}
 
Reply With Quote
 
 
 
 
TimDay TimDay is offline
Junior Member
Join Date: Jul 2006
Location: Atlanta
Posts: 2
 
      07-30-2006
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.
{04} 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} 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).
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lower bound & Upper bound sunil panda Java 9 10-07-2008 08:32 PM
Passing Bound Object value to another Bound Object Phillip Vong ASP .Net 0 07-27-2006 10:54 PM
How to represent the data in a not bound control via bound control Mario Krsnic ASP .Net 0 06-23-2006 07:38 AM
Getting lower-bound and upper-bound of strings input Rhiner Dan C++ 1 03-27-2005 02:03 AM
Data formatting expression wanted for dataset bound datagrid column for href Alex ASP .Net 0 04-14-2004 04:03 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57