DataFormatString with eval

2 posts, 0 answers
  1. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 24 Sep 2012 Link to this post

    I'm using this code. I want to show only date part. But it is stored as date time in db?How can we apply formatting when using eval
    <telerik:GridTemplateColumn>
                      <ItemTemplate>
                      <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Date of Arrival")%>'></asp:Label>
       </ItemTemplate>
                      </telerik:GridTemplateColumn>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Sep 2012 Link to this post

    HI,

    Try setting the DataFormatString as shown below.
    aspx:
    <telerik:GridTemplateColumn>
        <ItemTemplate>
              <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Date of arrival", "{0:dd-MM-yyyy}") %>'></asp:Label>
       </ItemTemplate>
    </telerik:GridTemplateColumn>

    Thanks,
    Shinu.
Back to Top