How to format negative currency with parentheses in asp.net

How to format negative currency with parentheses in asp.net

10 Aug 2011 03:08:30

Hi All,

This is not question, just a quick tip,
Today I have spent few hours for fix issue, format currency with parentheses instead of negative number.

There are two ways.

1.easy and simple

<asp:BoundField HeaderText="Member Discount" DataField="DiscountPer" DataFormatString="{0:#,##0.00;(#,##0.00);0}"
                                            ItemStyle-HorizontalAlign="Right" />

2.add few extra work,

<asp:TemplateField HeaderText="Member Discount ">
                                            <ItemTemplate>
                                                <asp:Label ID="Label1" runat="server" Text='<%# Convert.ToString(Eval("DiscountPer","{0:c}")).Replace("$", "") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>

Hope save your time.

Gold   Boarder
Posts: 156
From 03-Jun-2009
You're Points: 1106
Bookmark
^ Scroll to Top