Format DataItem 'inline' as Currency/String?

  • Thread starter D. Shane Fowlkes
  • Start date
D

D. Shane Fowlkes

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.DataItem("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...
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top