Reputation: 101
I want to display a Indain rupee symbol in my web-site. in my grid view when I use DataFormatString="{0:c2} it is showing $ symbol.
so any one tell me how to solve this problem
Upvotes: 1
Views: 13014
Reputation: 11
<system.web>
<globalization culture="en-IN"/>
</system.web>
/* To get a Rupees Symbol in WebForm include in system.web File under Web.Confiq */
Upvotes: 1
Reputation: 10565
Setting the UICulture
to hi
and Culture="hi-IN"
will display the Hindi Symbol: रु
for Rupees. [ Hindi is a language of India ]
If you want to display the symbol ₹
for an Indian Rupee, you can set the CultureInfo
and customize the currency sign for the Culture.
// Override the InitializeCulture()
method in your code behind file.
protected override void InitializeCulture()
{
CultureInfo ci = new CultureInfo("en-IN");
// assign your custom Rupee symbol of your country
ci.NumberFormat.CurrencySymbol = "₹";
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture
= ci;
base.InitializeCulture();
}
Now in your GridView you only need to specify the DataFormatString="{0:C}"
and HtmlEncode
as false
.
<asp:BoundField DataField="UnitPrice" DataFormatString="{0:C}"
HtmlEncode="false" />
Upvotes: 0
Reputation: 28437
You would be better off by setting the culture.
This can be done site-wide in the web.config, using the <globalization uiCulture="in" culture="in-IN" />
element, or at the page level in the page directive <%@ Page UICulture="in" Culture="in-IN" %>
(it is in-IN or hi-IN am not too sure)
Or simply this for one-off scenario: DataFormatString = ₹ + "{0:c2}";
Upvotes: 3