Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Format currency in ItemTemplate

Posted on 2011-02-24
6
Medium Priority
?
727 Views
Last Modified: 2012-05-11
Hi,
How would I get this to appear as currency.

<%# (Convert.ToDouble(Eval("Quantity")) *  Convert.ToDouble(Eval("UnitCost")))%>

this is in an asp.net 4.0 application
Thanks
0
Comment
Question by:Howard Katz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 18

Expert Comment

by:Anil Golamari
ID: 34972819
http://lawrence.ecorp.net/inet/samples/regexp-validate2.php ( Javascript function)

http://www.regexlib.com/DisplayPatterns.aspx (Regular Expression to validate)

decimal moneyvalue = your value;
string html = String.Format("Order Total: {0:C}", moneyvalue);
Console.WriteLine(html);

(C# String format code)
0
 
LVL 9

Expert Comment

by:mayank_joshi
ID: 34978262
<%# Format((Convert.ToDouble(Eval("Quantity")) *  Convert.ToDouble(Eval("UnitCost"))),"c")%>
0
 
LVL 2

Expert Comment

by:saritapatel
ID: 35004581
'<%#Format(Convert.ToDouble(Eval("netQty")*Eval("UnitCost")),"c") %>'
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:Howard Katz
ID: 35007809
Thanks to both of you but neither suggestion has an effect.  Here is the code that surrounds this line.  It is in a gridview.

<Columns>
<asp:BoundField DataField="ProductID" HeaderText="Product ID"  ....
<asp:BoundField DataField="ModelNumber" HeaderText="Model Number" ....
<asp:BoundField DataField="ModelName" HeaderText="Model Name" ....
<asp:BoundField DataField="UnitCost" HeaderText="Unit Cost" DataFormatString="{0:c}" />        
<asp:TemplateField>
    <HeaderTemplate>Quantity</HeaderTemplate>
    <ItemTemplate>
      <asp:TextBox  runat="server" Text='<%# Bind("Quantity") %>' />
    </ItemTemplate>
</asp:TemplateField>    
       
<asp:TemplateField>
    <HeaderTemplate>Item&nbsp;Total</HeaderTemplate>
    <ItemTemplate>
       <%# (Convert.ToDouble(Eval("Quantity")) *  Convert.ToDouble(Eval("UnitCost")))%>
    </ItemTemplate>

</asp:TemplateField>                
<asp:TemplateField>
    <HeaderTemplate>Remove&nbsp;Item</HeaderTemplate>
    <ItemTemplate>
          <center>
            <asp:CheckBox id="Remove" runat="server" />
          </center>
    </ItemTemplate>
</asp:TemplateField>
</Columns>
0
 

Accepted Solution

by:
Howard Katz earned 0 total points
ID: 35021308
I found the answer.  

<%# (Convert.ToDouble(Eval("Quantity")) * Convert.ToDouble(Eval("UnitCost"))).ToString("C2")%>  
0
 

Author Closing Comment

by:Howard Katz
ID: 37089838
What else should I do.
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Loops Section Overview

610 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