Converting a Data Type from a SQL Database when called in ASP

Posted on 2009-12-22
Last Modified: 2013-12-17
  I have a stored procedure pulling data from a SQL database for my ASP web page.  The data it's pulling is a integer, but I want it to display as a currency.  Any ideas?

The DetailsView currently looks like this:
<asp:DetailsView ID="DetailsView2" runat="server" AutoGenerateRows="False" DataKeyNames="InventoryID"
                        DataSourceID="SqlDataSource1" Height="50px" Width="153px" OnPageIndexChanging="DetailsView2_PageIndexChanging">
                            <asp:BoundField DataField="OEMPrice" HeaderText="Dealer Price:" ReadOnly="True" SortExpression="OEMPrice" />
                            <asp:BoundField DataField="Retailprice" HeaderText="Your Price:" SortExpression="Retailprice" DataFormatString="Currency" />
Question by:reedsster1
    LVL 12

    Expert Comment

    System.Globalization.NumberFormatInfo numberFormat = new System.Globalization.NumberFormatInfo();
    numberFormat.CurrencyNegativePattern = 1;
    numberFormat.CurrencySymbol = "$";
    int iAmount = 123;
    string sCurrency = iAmount.ToString("C0", numberFormat);

    Open in new window

    LVL 14

    Accepted Solution

    <asp:BoundField DataField="Retailprice" HeaderText="Your Price:" SortExpression="Retailprice" DataFormatString="{0:C}" />
    LVL 14

    Expert Comment

    by:Dhanasekaran Sengodan
    try this

    Also, with Eval method you can show formatted data. This syntax will format data as currency:


    Author Closing Comment

    Awesome.  Thanks

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    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…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    745 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

    18 Experts available now in Live!

    Get 1:1 Help Now