Solved

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

Posted on 2008-10-29
1
1,443 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp.net repeater server posting 5 35
GUID's in SQL Server 4 28
How to call new form in VB2013? 4 29
Delete command SQLdatasource in asp.net, vb 2 12
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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