Unable to change date format for text in the Eval function in asp:Label

Posted on 2011-10-14
Last Modified: 2012-05-12
I`m trying to change the format of a label that is getting its value from an Eval expression, e.g. Eval("DateModified"). See attached screenshot.

Peter ASPxLabel_DateFormatError
Question by:pbc83
    LVL 11

    Expert Comment

    <%# EVAL(ds,fldname).ToString("yyyy-MM-dd").ToString() %>

    try this way

    Assisted Solution

    Sorry rajvja that solution doesn't work.

    Accepted Solution

    I found the solution:

    <asp:Label ID="ModifiedLabel" runat="server" Text= '<%# DataBinder.Eval(Container.DataItem, "DateModified", "{0:MM/dd/yyyy}") %>' />

    This works!


    Author Closing Comment

    Solution works.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now