473,800 Members | 2,518 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Format DataItem 'inline' as Currency/String?

I have a DataItem in a Template that calls a Function to perform a
calculation. The Function returns a decimal value. Easy enough. It looks
like this:

<code>
<%# CalculateExpend ed(Container.Da taItem("StaffID ")) %>
</code>

So how exactly can I format this to come out as currency? I can NOT format
the output in the function. The function must return a decimal. I've tried
something like the code below but that returns a "'System.Decima l' does not
contain a property with the name {0:C}. " error.

<code>
<%# DataBinder.Eval (CalculateExpen ded(Container.D ataItem("StaffI D")),
"{0:C}") %>
</code>

Thanks

Just to emphasize - I cannot perform the formatting within the function! I
must do this at the Template's DataItem level in the page. Thanks again...
Nov 19 '05 #1
1 2019
Haven't tried, but how about:

string.format(" {0:c}", CalculateExpend ed(Container.Da taItem("StaffID ")))

or, while I sense you can't format the data in the function:), how about a
separate function, e.g. CalculateExpend edAsCurrency(co ntainer.dataite m,
etc.), where in the code-behind it calls CalculateExpend ed?

Bill

"D. Shane Fowlkes" wrote:
I have a DataItem in a Template that calls a Function to perform a
calculation. The Function returns a decimal value. Easy enough. It looks
like this:

<code>
<%# CalculateExpend ed(Container.Da taItem("StaffID ")) %>
</code>

So how exactly can I format this to come out as currency? I can NOT format
the output in the function. The function must return a decimal. I've tried
something like the code below but that returns a "'System.Decima l' does not
contain a property with the name {0:C}. " error.

<code>
<%# DataBinder.Eval (CalculateExpen ded(Container.D ataItem("StaffI D")),
"{0:C}") %>
</code>

Thanks

Just to emphasize - I cannot perform the formatting within the function! I
must do this at the Template's DataItem level in the page. Thanks again...

Nov 19 '05 #2

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

Similar topics

2
2239
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 SELECT * FROM qryStatementI UNION SELECT * FROM qryStatementP ORDER BY thedate;
4
22606
by: Gerry Abbott | last post by:
Hi All. How can i put a zero decimal for my currency into my format statement, == & ", for " & & " days. Cost " & Format(,"Currency") which is the data source for a textbox on a report
1
7094
by: Brent Jenny | last post by:
I have the following function that takes in a string, converts it to a double and adds it to a running total. I wnat to format it on return to mey datagrid template column as currency. iget the following build error The best overloaded method match for 'string.ToString(System.IFormatProvider)' has some invalid arguments. The error happens on my return statement. Any ideas? public string po_count(string po)
1
2839
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 as this format: $30,000.00, because I put it this format {0:C}. I need to re-format as only this value (example: 30.000 - without currency, without decimal & using dot for thousand separator). But how to re-format my
3
4873
by: JeffP | last post by:
In the datagrid I have $320.00 from... <asp:Label ... Text='<%# DataBinder.Eval(Container, "DataItem.Install_1", "{0:c}") %>' ...> How can I get: $320
15
2602
by: Laser Lu | last post by:
Hi, all, I was tangled by the DataGridItem.DataItem property. I tried to invoke that property to get and display the contents that was bound to the currently selected row. However, an exception surprised me that it said "Object reference not set to an instance of an object." How could it happen? I have set the data source, and called the DataBind(). I looked up the MSDN documents, and just find some inessential descriptions, and a code...
1
2716
by: D. Shane Fowlkes | last post by:
Quick question - I have output from a Money MS SQL field going into a repeater's dataitem. The db does not store any cents (decimals). How can I get this on the page: <%#DataBinder.Eval(Container.DataItem, "Revenue", "{0:C}")%> ...NOT to display any decimals or cents?
2
1587
by: crferguson | last post by:
Hello all! I'm having the oddest issue trying to format a numeric string as currency without decimals. For instance... strSalary = "120000.56" strSalary = Format(strSalary, "$#,##0") 'this one returns "$#,##0" literally, no number strSalary = Format(strSalary, "C0") 'this one returns "C0" literally, no number
6
3681
by: JFB | last post by:
Hi all, How can I format a fax number as 888-333-444? The number is coming from database as 8883334444 <ItemTemplate> <%#container.dataItem("cfax")%> </ItemTemplate> Tks JFB
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10501
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10250
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7574
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.