Solved

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

Posted on 2008-10-29
1
1,441 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:bryanche
1 Comment
 

Accepted Solution

by:
bryanche earned 0 total points
ID: 22835017
I found the solution myself. what I had to do was to wrap my output number data around "FormatCurrency" method.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question