Format string

Posted on 2008-11-19
Last Modified: 2012-05-05
I have this code and i need format the field price for 2 decimal places:
<%#DataBinder.Eval(Container.DataItem, "price").ToString()%>
How can do it
Question by:rflorencio
    LVL 15

    Assisted Solution

    by:David L. Hansen
    formatCurrency(myValue, 2)

    Author Comment

    the code works but the currency symbol ¬ appears in the right, it´s possible remove symbol.
    LVL 12

    Accepted Solution

    Hi do this:
    <%#DataBinder.Eval(Container.DataItem, "price","{0:n2}").ToString()%>
    LVL 18

    Assisted Solution

    you could put your format string
    for 2 decimal,
    <%#DataBinder.Eval(Container.DataItem, "price").ToString("N02")%>

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    729 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

    20 Experts available now in Live!

    Get 1:1 Help Now