473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Format a field into currency

Hi, I currently have a field which stores an amount in the database as
an integer. It is stored as cents, so 155 in the databse it is really
$1.55.

Problem is when I Bind it to a datagrid using the Text='<%#
Bind("RecurringPaymentAmount", "{0:c2}") %>'>, it displays as $155.00
instead of $1.55.

Any idea how to easily format this so it displays correctly.

Thanks in advance.

Peter.

<asp:TemplateField HeaderText="Recurring Amount"
SortExpression="RecurringPaymentAmount">
<ItemTemplate>
<asp:Label ID="lblRecurringPaymentAmount" runat="server"
Text='<%# Bind("RecurringPaymentAmount", "{0:c2}") %>'></asp:Label>
</ItemTemplate>
<asp:TemplateField>

Apr 16 '07 #1
2 7796
When requesting the data from the database, divide it by 100. For example:
SELECT CAST(cents AS money) / 100 AS dollars
FROM Table

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"pe***@eway.com.au" wrote:
Hi, I currently have a field which stores an amount in the database as
an integer. It is stored as cents, so 155 in the databse it is really
$1.55.

Problem is when I Bind it to a datagrid using the Text='<%#
Bind("RecurringPaymentAmount", "{0:c2}") %>'>, it displays as $155.00
instead of $1.55.

Any idea how to easily format this so it displays correctly.

Thanks in advance.

Peter.

<asp:TemplateField HeaderText="Recurring Amount"
SortExpression="RecurringPaymentAmount">
<ItemTemplate>
<asp:Label ID="lblRecurringPaymentAmount" runat="server"
Text='<%# Bind("RecurringPaymentAmount", "{0:c2}") %>'></asp:Label>
</ItemTemplate>
<asp:TemplateField>

Apr 16 '07 #2
On Apr 17, 1:10 am, Peter Ritchie [C# MVP] <PRS...@newsgroups.nospam>
wrote:
When requesting the data from the database, divide it by 100. For example:
SELECT CAST(cents AS money) / 100 AS dollars
FROM Table

--
Browsehttp://connect.microsoft.com/VisualStudio/feedback/and vote.http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#

"p...@eway.com.au" wrote:
Hi, I currently have a field which stores an amount in the database as
an integer. It is stored as cents, so 155 in the databse it is really
$1.55.
Problem is when I Bind it to a datagrid using the Text='<%#
Bind("RecurringPaymentAmount", "{0:c2}") %>'>, it displays as $155.00
instead of $1.55.
Any idea how to easily format this so it displays correctly.
Thanks in advance.
Peter.
<asp:TemplateField HeaderText="Recurring Amount"
SortExpression="RecurringPaymentAmount">
<ItemTemplate>
<asp:Label ID="lblRecurringPaymentAmount" runat="server"
Text='<%# Bind("RecurringPaymentAmount", "{0:c2}") %>'></asp:Label>
</ItemTemplate>
<asp:TemplateField>- Hide quoted text -

- Show quoted text -
Thanks Peter, I did that, tho when i click to edit the row (in the
grid view) it displays the value in the ItemEditField template as
150.0000 for some reason.

any ideas?

Apr 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Micromanaged | last post by:
In my response.write line, I need to format a field to be a currency value. Is there a quick and dirty way to do it or is it an involved edit? Here is my code: Response.Write("<td>" &...
3
by: John H. | last post by:
Hi, Why if set a DataTable in Crystal Report Net Table with method SetDataSource, 'ReportDocument.SetDataSource(oDataTable)', lost the Number and Currency format with the decimal digits and...
2
by: Dalan | last post by:
This should not be an issue, but it is. I'm sure that someone knows what little piece of code is needed too persuade Access 97 to include a currency format for labels (Avery, mailing type). Have...
2
by: DD | last post by:
I have a UnionQry that is run from StatementsI and StatementP. the Due and Paid colunms are currency and show the $ however when i union the two the currency format has gone. Any help please...
3
by: Scott Gorman | last post by:
I have created a report in access. I had to add a text box to input a value for previous months balance. I have formatted to display with $ currency, and also with the " , " for thousand separator....
3
by: Claudia Fong | last post by:
Hi, My db is stored in access and I have a field amount and its type is currency. When I read from the db and display it in a textbox, it shows me 15000000 instead of $150,000.00. How can...
1
by: Nigel C | last post by:
Hi, I am going round in circles... I am trying to produce a report based upon the information gathered into a temp table. Each column (stored as a text field) in the table holds weekly...
1
by: Julius Fenata | last post by:
Dear all, I need help to change my item-template value format... Here is my case, I have a datagrid, with 'SubjectPrice' field, and when the grid displayed, my 'SubjectPrice' field displayed...
5
by: ramaswamynanda | last post by:
Hello, I have a currency field on my form. The default formats for this field are dollar, euro. There is no pound symbol.....How do i put in a currency format, having the pound sign. Any help...
2
by: Dhananjay | last post by:
Hi all , I have got problem when i am tring to exportGridview Data into Excel format. It is going into text format ,but what i want is if the field is number/currency then it should go into...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.