Date format without time in ASP.NET Gridview

in ASP.NET gridview binding two dates. I want to display dd/MM/yyyy but it displays 10/03/2014 00:00:00.

<asp:TemplateField HeaderText ="Fromdate" >
   <ItemTemplate >
   <asp:Label ID="lblFromDate" runat="server" 
              DataFormatString="{0:dd/MM/yyyy}" 
              HtmlEncode="false"  
              Text='<%# Eval("Fromdate") %>' />
    </ItemTemplate>
</asp:TemplateField>

Solution 1:

DataFormatString is a property of BoundField control and doesn't affect any other control. You can specify the format in an Eval expression:

Text='<%# Eval("Fromdate", "{0:dd/MM/yyyy}") %>' />

Solution 2:

According to this article on MSDN the DataFormatString attribute has a limited number of variants for DateTime data.

What you are looking for is:

DataFormatString="{0:d}"

which is the short date pattern.

In order to get the dd/MM/yyyy format, you need to also set your culture info properly (for example to **en-GB**).