Link to home
Start Free TrialLog in
Avatar of bryanche
bryanche

asked on

How to format a BoundField in GridView to show a $ with 2 decimal points?

Hi experts!
I have the following code but the format is not working for me for some strange reason. Need your directions please. The fields I want to format like $0.00. These two fields in database have type of money. The output I get in my GridView is like 0.0000
I appreciate your help in advance.
<asp:GridView ID="gvReverseNoList" Font-Size="12px" Font-Names="Arial" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
	<columns>
		<asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" >
			<ItemStyle HorizontalAlign="Left" VerticalAlign="middle" />
		</asp:BoundField>
		<asp:BoundField DataField="Loss" HeaderText="Loss" SortExpression="Loss" HtmlEncode="false" HtmlEncodeFormatString="false" DataFormatString="{0:c}" >
			<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
		</asp:BoundField>                                        
		<asp:BoundField DataField="Expense" HeaderText="Expense" SortExpression="Expense" HtmlEncode="false" HtmlEncodeFormatString="false" DataFormatString="{0:c}" >
			<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
		</asp:BoundField>                                        
	</columns>
	<PagerSettings FirstPageText="First Page" LastPageText="Last Page" NextPageText="Next Page" PreviousPageText="Previous Page" />
	<FooterStyle BackColor="#7A829D" Font-Bold="True" ForeColor="White" />
	<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
	<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Left" />
	<SelectedRowStyle BackColor="#E2DED6" Font-Bold="False" ForeColor="#333333" />
	<HeaderStyle HorizontalAlign="left" BackColor="#FFFFFF" Font-Bold="True" ForeColor="Black" />
	<EditRowStyle BackColor="#999999" />
	<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of bryanche
bryanche

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