|
-
Oct 7th, 2005, 10:14 AM
#1
Thread Starter
New Member
Formatting currency using Databinder.Eval method
Hi all
I'm trying to format a currency as well as a date using code that I found in MSDN. The actual MSDN page:
http://msdn.microsoft.com/library/de...sevaltopic.asp
The actual code on my ASP.NET page:
<td class="DataCell" style="width=100px"><nobr><%# DataBinder.Eval(Container.DataItem, "unit_cost", "{0:c}") %></nobr></td>
It's exactly the same line, but the data still outputs on the page as an unformatted currency. I've tried uppercase "C" and lowercase "c", but it just seems to ignore the format parameter. Am I doing something wrong here?
Any help appreciated. P.S. Can anyone tell me what I have to wrap around my text to make the code appear as "code"?
Thanks.
-
Oct 10th, 2005, 03:35 PM
#2
Fanatic Member
Re: Formatting currency using Databinder.Eval method
I've not had a chance to test you problem out, but thought should help out with your second question.
You place either of the following tags around your code (note: I've used backslash before each square bracket to prevent the tags from rendering.
\[code\] your code goes here \[/code\]
\[vbcode\]your code goes here\[/vbcode\]
if you use IE then this is an excellent tool showthread
If you use the main post new thread page there is a toolbar one of the options is vbCode just hilight your code then click the toolbar item and it will insert the tags
-
Oct 10th, 2005, 03:39 PM
#3
Re: Formatting currency using Databinder.Eval method
For the sake of clarity, the above examples would be used exactly like:
[code]YOUR CODE[/code]
or
[vbcode]YOUR CODE[/Highlight]
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 11th, 2005, 07:13 AM
#4
New Member
Re: Formatting currency using Databinder.Eval method
try one of the following
Code:
<ASP:BOUNDCOLUMN datafield="UnitPrice" sortexpression="UnitPrice" headertext="UnitPrice" dataformatstring="{0:c}"></ASP:BOUNDCOLUMN>
OR
Code:
<ASP:TEMPLATECOLUMN headertext="UnitPrice">
<ITEMTEMPLATE>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.UnitPrice", "{0:c}") %>'>
</ASP:LABEL>
</ITEMTEMPLATE>
</ASP:TEMPLATECOLUMN>
Hope this helps
Just because you're paranoid doesn't mean they aren't out to get you
Quidquid latine dictum sit, altum viditur
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|