Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 286
  • Last Modified:

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

Hello
  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">
                        <Fields>
                            <asp:BoundField DataField="OEMPrice" HeaderText="Dealer Price:" ReadOnly="True" SortExpression="OEMPrice" />
                            <asp:BoundField DataField="Retailprice" HeaderText="Your Price:" SortExpression="Retailprice" DataFormatString="Currency" />
0
reedsster1
Asked:
reedsster1
  • 2
1 Solution
 
CB_ThirumalaiCommented:
Example
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

0
 
Dhanasekaran SengodanCommented:
<asp:BoundField DataField="Retailprice" HeaderText="Your Price:" SortExpression="Retailprice" DataFormatString="{0:C}" />
0
 
Dhanasekaran SengodanCommented:
try this

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

<%#Eval("Price","{0:c}")%>
0
 
reedsster1Author Commented:
Awesome.  Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now