473,320 Members | 1,957 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,320 software developers and data experts.

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>
<%# CalculateExpended(Container.DataItem("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.Decimal' does not
contain a property with the name {0:C}. " error.

<code>
<%# DataBinder.Eval(CalculateExpended(Container.DataIt em("StaffID")),
"{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 2008
Haven't tried, but how about:

string.format("{0:c}", CalculateExpended(Container.DataItem("StaffID")))

or, while I sense you can't format the data in the function:), how about a
separate function, e.g. CalculateExpendedAsCurrency(container.dataitem,
etc.), where in the code-behind it calls CalculateExpended?

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>
<%# CalculateExpended(Container.DataItem("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.Decimal' does not
contain a property with the name {0:C}. " error.

<code>
<%# DataBinder.Eval(CalculateExpended(Container.DataIt em("StaffID")),
"{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
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...
4
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
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...
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...
3
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
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...
1
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: ...
2
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...
6
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.