Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

JGresko (Programmer) (OP)
4 Oct 02 9:50

I have an ASP.NET datagrid on a page that contains a bound date column.  The Visual Studio DataGrid property builder asks for a "Data Formatting Expression", but I can't get it to accept any syntax I've tried.

The MS help files on bound columns say:

"Using bound columns in a DataGrid Web server control allows you to specify which columns from the data source to display, customize the header and footer for each column, and control sorting."

... note nothing on formatting

When I use dynamic help from the builder I get:
"A .NET framework formatting expression that is applied to the data before it is displayed in the column. This is particularly useful for specifying the format of dates, currency, and numbers, but can be specified for any data."

... not very helpful since there are no examples anywhere that I can find that work.

Can someone please give me some examples to try?  I just want to display the date without the time.



Helpful Member!  netangel (Programmer)
4 Oct 02 11:17
That's true. There is little or nothing about formating. It took me years to figure it out.

Try putting {0:dd/MM/yyyy} on that field, to show the date with out the time.

Hope this helps.


JGresko (Programmer) (OP)
4 Oct 02 11:29

That's it!!! Thank You NetAngel!!!
Helpful Member!  Zarcom (Programmer)
4 Oct 02 12:21
The .Net stuff has actually simplified that syntax alot.  If you use the databinding property box in a datalist it actually gives you all/some of the formatting expressions.

I actually copied this so that I don't forget so here they are.
General -    {0}
Short Time -    {0:t}
Long Time -    {0:T}
Short Date -    {0:d}
Long Date -    {0:D}
Date & Time -    {0:g}
Full Date -    {0:G}

Number -    {0:N}
Decimal -    {0:D}
Fixed Point -    {0:F}
Currency -    {0:C}
Scientific -    {0:E}
Hexadecimal -    0x{0:X}

That'l do donkey, that'l do
If you are unsure of forum etiquette check here FAQ796-2540

netangel (Programmer)
4 Oct 02 12:33
That's quite usefull when you live in US. Everyone has US Regional Settings.

I live in Portugal. As some people use english and other use portuguese windows versions, and most people don't even bother changing their regional settings, it can cause a LOT of bugs to use those 'shortcuts'. Besides if people look at their application and see a date or time formated in a 'strange' way, they phone immediatly saying the app has a bug and strange chars appear on the middle of the date (it has happened before - most ordinary users don't know the meaning of AM/PM).

I'm just trying to warn to this sort of problem. If you are sure people have their regional settings correct, USE IT. That's great.


Zarcom (Programmer)
4 Oct 02 12:45
Thanks for that Net Angel.  I didn't realize they were US regional settings.

That'l do donkey, that'l do
If you are unsure of forum etiquette check here FAQ796-2540

netangel (Programmer)
4 Oct 02 12:50
They are not US regional settings. They depend on the computer's regional settings. The problem is that most the people doesn't change them because they don't know or don't care.

Then when they see different formats they don't understand and assume that's a bug.


Zarcom (Programmer)
4 Oct 02 13:14
Oh so I was right in a way.  Getting confused here but I got it now.
I was at first under the understanding (correctly) that those formatting strings would format depending on regional settings.  Which is why I was suggesting them.  Your application is then more dynamic, displaying different settings to different users.  Assuming they have changed their settings.

Your saying you don't trust people to change their settings and so program your application to display information in a way familiar to the majority of your viewing audience.

Done deal

That'l do donkey, that'l do
If you are unsure of forum etiquette check here FAQ796-2540

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close