Assuming that the underline datatype of your DiscountTotal
property is System.Decimal, you could use this in order to provide the appropriated culture to the ToString
method, so it can render the currency symbol based on the specified culture.
// For $, use en-US instead of en-GB.
// You must make this available in your session.
var sessionUiCulture = new System.Globalization.CultureInfo("en-GB");
...
...
<%# decimal.Round((decimal)DataBinder.Eval(Container.DataItem, "DiscountTotal"), 2, MidpointRounding.ToEven).ToString("C", sessionUiCulture) %>
Also, if you need this behavior across your application, the best way to accomplish this is by setting the property System.Globalization.CultureInfo.CurrentUICulture
to the appropriated culture in your request pipeline, this way you don't have to worry about this.
Depending on what route you go, you should consider creating an extension method for this:
public static string ToCurrency(this decimal value)
{
return decimal.Round(value, 2, MidpointRounding.ToEven).ToString("C");
}
So you could just do:
<%# ((decimal)DataBinder.Eval(Container.DataItem, "DiscountTotal")).ToCurrency() %>