Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Displaying short date format in GridView
Message
 
À
06/10/2010 16:07:00
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01484208
Message ID:
01484244
Vues:
18
>>>Hi,
>>>
>>>I am trying to display just the date part of a datetime field in a gridview, but the time is always displayed. Can anybody see anything wrong with this?
>>>
>>>
<ItemTemplate>
>>>     <mm:mmLabel ID="lblDOB" runat="server" DisplayFormat="{0:d}" CssClass="date" Text='< %# Bind("DateOfBirth") % >'></mm:mmLabel>
>>></ItemTemplate>
>>
>>
>>I don't use MM, but you should be able to do something like..
>>
>><mm:mmLabel ID="lblDOB" runat="server" CssClass="date" Text='< %# DateTime.Parse(Eval("DateOfBirth")).ToShortDateString() % '></mm:mmLabel>
>>
>>
>>Since it is a label, Eval makes a little more sense..
>>
>>Hopefully your date CSSClass isn't interfering.
>
>William,
>
>I get this error with your suggestion:
>
>
Compiler Error Message: CS1502: The best overloaded method match for 'System.DateTime.Parse(string)' has some invalid arguments
>
>This is the exact code I used (except of course the space around the % signs):
>
>
<mm:mmLabel ID="lblDOB" runat="server" DisplayFormat="{0:d}" CssClass="date" Text='< %# DateTime.Parse(Eval("DateOfBirth")).ToShortDateString() % >'></mm:mmLabel>
>
>The CSSClass is not interfering, I had actually added that in as an attempt to get it to work, but it didn't help.

Try..
<mm:mmLabel ID="lblDOB" runat="server" DisplayFormat="{0:d}" CssClass="date" Text='< %# DateTime.Parse(Eval(Container.DataItem,"DateOfBirth")).ToShortDateString() % >'></mm:mmLabel>
____________________________________

Don't Tread on Me

Overthrow the federal government NOW!
____________________________________
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform