gianitoo
asked on
negative currency in gridview
My positive amounts are displaying like this $75.00
My negative amounts are displaying like this ($75.00)
I need my positive to stay the same and my negative to display -$75.00
<asp:BoundField DataField="unit_price1" DataFormatString="{0:c}"
HeaderText="Price" HtmlEncode="False" SortExpression="unit_price 1"
ItemStyle-HorizontalAlign= "center" ControlStyle-CssClass="tit leboldpric e" ItemStyle-CssClass="titleb oldprice">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
My negative amounts are displaying like this ($75.00)
I need my positive to stay the same and my negative to display -$75.00
<asp:BoundField DataField="unit_price1" DataFormatString="{0:c}"
HeaderText="Price" HtmlEncode="False" SortExpression="unit_price
ItemStyle-HorizontalAlign=
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
ASKER
So how do i apply that in my gridview?? gridview below
field for price is unit_price1
<asp:GridView ID="GridView4" runat="server" AutoGenerateColumns="False "
DataKeyNames="rowpointer" DataSourceID="SqlDataSourc e4" GridLines="None"
EmptyDataText="No Options"
OnRowDataBound="GridView4_ RowDataBou nd" ShowHeader="False">
<RowStyle BackColor="White" ForeColor="#003399" />
<Columns>
<asp:BoundField DataField="itemdescription " HeaderText="Items"
HtmlEncode="True"/>
<asp:BoundField DataField="unit_price1" DataFormatString="{0:c}"
HeaderText="Price" HtmlEncode="False" SortExpression="unit_price 1"
ItemStyle-HorizontalAlign= "center" ControlStyle-CssClass="tit leboldpric e" ItemStyle-CssClass="titleb oldprice">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField><ItemTe mplate>
<asp:HyperLink ID="deleteme" runat="server" >Remove</asp:HyperLink>
</ItemTemplate></asp:Templ ateField>
<asp:TemplateField HeaderText="Price">
<FooterTemplate>
<asp:Label ID="lblSummary" Runat="server" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
field for price is unit_price1
<asp:GridView ID="GridView4" runat="server" AutoGenerateColumns="False
DataKeyNames="rowpointer" DataSourceID="SqlDataSourc
EmptyDataText="No Options"
OnRowDataBound="GridView4_
<RowStyle BackColor="White" ForeColor="#003399" />
<Columns>
<asp:BoundField DataField="itemdescription
HtmlEncode="True"/>
<asp:BoundField DataField="unit_price1" DataFormatString="{0:c}"
HeaderText="Price" HtmlEncode="False" SortExpression="unit_price
ItemStyle-HorizontalAlign=
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField><ItemTe
<asp:HyperLink ID="deleteme" runat="server" >Remove</asp:HyperLink>
</ItemTemplate></asp:Templ
<asp:TemplateField HeaderText="Price">
<FooterTemplate>
<asp:Label ID="lblSummary" Runat="server" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DataFormatString="{0:c}"
is where your problem is
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
Open in new window