Solved

Format currency in ItemTemplate

Posted on 2011-02-24
6
720 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:katzhoward
[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
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 

Author Comment

by:katzhoward
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:
katzhoward 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:katzhoward
ID: 37089838
What else should I do.
0

Featured Post

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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