Solved

formatting a decimal inside repeater

Posted on 2011-02-11
4
798 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

861 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

23 Experts available now in Live!

Get 1:1 Help Now