format currency in a repeater

In ASP.NET 2.0 with C# I have a repeater that is bounded to a datatanle.
I have there  inside a <td> the following field:
 <%# Eval("MinPrice")%>
If I write it like this:  <%# Eval("MinPrice", "{0:C}")%>  it does not show the currency sign
so I want to prepare it in the code behind in the repeater ItemDataBound event.
If I do there:
string AmountStr1 = String.Format("{0:C}", decimal.Parse(tempAmount));
I get the appropriate value. but in the databound event of the repeater I know how to deal with values from controls like button, hyperlink, hiddenfiels. but what do I do with value that is a field in the repeater but has no control?
How do I work on it and return it to the repeater?
Thankyou
Anat
ANAT2403Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ANAT2403Connect With a Mentor Author Commented:
Hi,
In the repeater I did not find an option of HtmlEncode="false"  but I manage to solve the problem in the
code behind like this:
            Label lblMax = (Label)e.Item.FindControl("lblMaxPrice");
            string maxpStr = String.Format("{0:C}", decimal.Parse(lblMax.Text));
            lblMax.Text = maxpStr.ToString();
Anat
0
 
Mortaza DoulatyCommented:
You can use:

<%#String.Format("{0:C}", Eval("[Amount_mny]"))%>

Open in new window

0
 
Dustin HopkinsSenior Web DeveloperCommented:
Since you want to do this in the code behind, instead of using the event create a function and send the eval to it.
Front End

<asp:Label ID="Label1" runat="server" Text='<%# formatcurrency(Eval("MinPrice")) %>' ></asp:Label>

Code behind:
public object formatcurrency(double amount)
{
    return amount.ToString("c");
}
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
hamidovtCommented:
<%# Eval("MinPrice", "{0:C}")%>   should work fine,  just add HtmlEncode="false" to your datagrid, repeater or whatever control you have...
0
 
Mortaza DoulatyCommented:
This would certainly solve your problem:

<%#string.Format("{0:C}", Eval("[Amount_mny]"))%>

Open in new window

0
 
ANAT2403Author Commented:
Hi,
Sorry but still only the dealing in code behind work.
Anat
0
 
Vee_ModCommented:
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.