|
Question : ASP.NET Grid Number Formatting
|
|
I have set my column fomatting as DataFormatString="{0:N}". I have make sure in my regional settings as US (ie decimal symbol as . and digit grouping as ,).
But in my grid(and also in my crystal report) the number appear as 1.234.456,00
Why is this so ? How to make it follow then setting in Regional Settings ? ie 1,234,343.00
Thank you.
|
|
Answer : ASP.NET Grid Number Formatting
|
|
.NET Framework Class Library
NumberFormatInfo Class Requirements Namespace: System.Globalization
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family
Assembly: Mscorlib (in Mscorlib.dll) Language C#
C++
JScript
Visual Basic
Show All Defines how numeric values are formatted and displayed, depending on the culture.
For a list of all members of this type, see NumberFormatInfo Members.
System.Object System.Globalization.NumberFormatInfo
[Visual Basic]
NotInheritable Public Class NumberFormatInfo Implements ICloneable, IFormatProvider [C#] [Serializable] public sealed class NumberFormatInfo : ICloneable, IFormatProvider [C++] [Serializable] public __gc __sealed class NumberFormatInfo : public ICloneable, IFormatProvider [JScript] public Serializable class NumberFormatInfo implements ICloneable, IFormatProvider Thread Safety This type is safe for multithreaded operations.
Remarks This class contains information, such as currency, decimal separators, and other numeric symbols.
To create a NumberFormatInfo for a specific culture, create a CultureInfo for that culture and retrieve the CultureInfo.NumberFormat property. To create a NumberFormatInfo for the culture of the current thread, use the CurrentInfo property. To create a NumberFormatInfo for the invariant culture, use the InvariantInfo property for a read-only version, or use the NumberFormatInfo constructor for a writable version. It is not possible to create a NumberFormatInfo for a neutral culture.
The user might choose to override some of the values associated with the current culture of Windows through Regional and Language Options (or Regional Options or Regional Settings) in Control Panel. For example, the user might choose to display the date in a different format or to use a currency other than the default for the culture. If the CultureInfo.UseUserOverride property is set to true, the properties of the CultureInfo.DateTimeFormat instance, the CultureInfo.NumberFormat instance, and the CultureInfo.TextInfo instance are also retrieved from the user settings. If the user settings are incompatible with the culture associated with the CultureInfo (for example, if the selected calendar is not one of the OptionalCalendars), the results of the methods and the values of the properties are undefined.
Numeric values are formatted using standard or custom patterns stored in the properties of a NumberFormatInfo. To modify how a value is displayed, the NumberFormatInfo must be writable so custom patterns can be saved in its properties.
The following table lists the standard format characters for each standard pattern and the associated NumberFormatInfo property that can be set to modify the standard pattern.
Format Character Description and Associated Properties c, C Currency format. CurrencyNegativePattern, CurrencyPositivePattern, CurrencySymbol, CurrencyGroupSizes, CurrencyGroupSeparator, CurrencyDecimalDigits, CurrencyDecimalSeparator. d, D Decimal format. e, E Scientific (exponential) format. f, F Fixed-point format. g, G General format. n, N Number format. NumberNegativePattern, NumberGroupSizes, NumberGroupSeparator, NumberDecimalDigits, NumberDecimalSeparator. r, R Roundtrip format, which ensures that numbers converted to strings will have the same value when they are converted back to numbers. x, X Hexadecimal format.
A DateTimeFormatInfo or a NumberFormatInfo can be created only for the invariant culture or for specific cultures, not for neutral cultures. For more information about the invariant culture, specific cultures, and neutral cultures, see the CultureInfo class.
This class implements the ICloneable interface to enable duplication of NumberFormatInfo objects. It also implements IFormatProvider to supply formatting information to applications.
Requirements Namespace: System.Globalization
|
|
|
|