legendgod Posted June 20, 2004 Posted June 20, 2004 I have a datagrid which one of the row display the datetime in this way: 2/6/2004 1:00:00 The code is like that: <asp:TemplateColumn HeaderText="Date"> <ItemTemplate> <asp:Label runat="server" text='<%# (DataBinder.Eval(Container.DataItem,"schStartTime")) %>' id="DateLabel"></asp:Label> </ItemTemplate> </asp:TemplateColumn> How can I modify the code so that it display the datetime like it: (a) 2 Jun; and (b) 01:00? Thank you Quote http://blog.legendgod.com
Arch4ngel Posted June 21, 2004 Posted June 21, 2004 (edited) Date formatting Look at Data Formatting Expression in the Columns property. {0} : show you the date (like you're seeing it right now) {0:d}: show you the date in ShortDate format More info on this here [EDIT] So for your case ... 1) {0: dd MM} 2) {0: hh:mm} Here you go [/EDIT] Edited June 21, 2004 by Arch4ngel Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.