Link to home
Start Free TrialLog in
Avatar of scm0sml
scm0sml

asked on

formatting a decimal inside repeater

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

SOLUTION
Avatar of s_chilkury
s_chilkury
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of scm0sml
scm0sml

ASKER

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>          
 
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of scm0sml

ASKER

Go the answer myself.

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