Date Format in GridView Databound/Template

The datetime field in the grid view is formatted in two ways,

databound field

<asp:BoundField DataField=”DateUpdate” HeaderText=”Updated” SortExpression=”DateUpdate” DataFormatString=”{0:dd/MM/yy HH:mm}”  ></asp:BoundField>

temlate field

<asp:TemplateFieldHeaderText=”Due Date” SortExpression=”DueDate” >

<ItemTemplate>

<asp:LabelID=”lblDueDate” runat=”server” Text=’<%# Eval(“DueDate”,”{0:dd/MM/yy}”)%>’ > </asp:Label>  

</ItemTemplate>

</asp:TemplateField>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s