Formatting numbers in a repeater control

zachvaldez
zachvaldez used Ask the Experts™
on
My output of number in my repeater control displays as for example 1000 and I prefer with a comma as 1,000

here's the code..

                 <td>
                                                <asp:Label ID="lblActMin" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ACTUAL_MINIMUM")%>'></asp:Label>


                                            </td>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Ryan ChongSoftware Team Lead

Commented:
you can write and then call the “custom function” to format the output.

Author

Commented:
May I request for the code that formats it please?

Author

Commented:
                              <td>
                                   <asp:Label ID="lblActMin" runat="server" Text='<%# DataBinder.Eval (Container.DataItem, "ACTUAL_MINIMUM")%>'></asp:Label>


                                            </td>

Open in new window


I just want to format the text to display as 1,000.00 and not 1000.00
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Author

Commented:
As I do not get a response, can the admin just delete this question please?
Software Team Lead
Commented:
sorry as was away for quite some time...

try:

<%# Eval("ACTUAL_MINIMUM", "{0:#,0.00}") %>

Open in new window


or create a custom function like:

<%# Format(Eval("ACTUAL_MINIMUM")) %>

Open in new window


then:

protected string Format(object v)
        {
            return ((decimal)v).ToString("#,0.00");
        }

Open in new window

Author

Commented:
that wad great! thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial