views:

12

answers:

1

I have written the following in my gridview i would like to show only date to the user i did not need time how to format it

       <asp:TemplateField>
                    <EditItemTemplate>
                        <asp:Label ID="lblPurchasedDate1" runat="server"  Text='<%# Eval("purchaseDate") %>'
                            Width="61px"></asp:Label>
                    </EditItemTemplate>
                    <HeaderTemplate>
                        PurchasedDate
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblPurchasedDate" runat="server" Text='<%# Eval("purchaseDate") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
+1  A: 

You can specify formatting options for Eval. You can either use the generic format codes, or specify a fixed format:

Eval("purchaseDate", "{0:d}")

Or

Eval("purchaseDate", "{0:dd/MM/yyyy}")

Richard