Solved

formatting a decimal inside repeater

Posted on 2011-02-11
4
809 Views
Last Modified: 2012-05-11
Hi,
I have the repeater below.

The value that InvoiceAmount is giving is:
512.33000 or whatever - it is a decimal.

I need to format it to 2 decimal place.

I have tried:
<%#DataBinder.Eval(Container.DataItem, "InvoiceAmount").ToString("#00.00")%>

but get:
 System.FormatException: Input string was not in a correct format.

What am I doing wrong?
<asp:Repeater ID="rptResults" runat="server" >                                       
                        <ItemTemplate>
                        <tr>
                            <td>                                
                                <%#DataBinder.Eval(Container.DataItem, "RegNumber")%>
                            </td>
                            <td>
                                <%#DataBinder.Eval(Container.DataItem, "SupplierOnInvoice.Name")%>
                            </td>
                            <td>
                                <%#DataBinder.Eval(Container.DataItem, "Payee.Name")%>
                           </td>                               
                           <td>
                                <%#DataBinder.Eval(Container.DataItem, "InvoiceAmount")%>
                           </td>                                                       
                            
                        </tr>            
                        </ItemTemplate>                            
                    </asp:Repeater>

Open in new window

0
Comment
Question by:scm0sml
[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
  • 3
4 Comments
 
LVL 9

Assisted Solution

by:s_chilkury
s_chilkury earned 200 total points
ID: 34871314
Change to:

<%#DataBinder.Eval(Container.DataItem, "InvoiceAmount", "{0:d}")%>
0
 

Author Comment

by:scm0sml
ID: 34871334
System.FormatException: Format specifier was invalid.

Source Error:


Line 187:                           </td>                              
Line 188:                           <td>
Line 189:                                <%#DataBinder.Eval(Container.DataItem, "InvoiceAmount", "{0:d}")%>
Line 190:                           </td>          
 
0
 

Accepted Solution

by:
scm0sml earned 0 total points
ID: 34905464
This works:
<%#DataBinder.Eval(Container.DataItem, "InvoiceAmount", "{0:F2}")%>

found it at it:
http://connect.microsoft.com/VisualStudio/feedback/details/324166/format-specifier-invalid-exception-introduced-by-net-2-0-sp1
0
 

Author Closing Comment

by:scm0sml
ID: 34941233
Go the answer myself.

One answer was correct for an old framework so have given some points.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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