Setting property for ASP.Net percentage format

Aptegy, for which I have no doubt, is a question of nob.

I am showing multiple percentage values ​​in a grid view in ASP.Net

I want to be able to set the NumberFormatInfo.PercentPositivePattern property , which I think I need to bring the "Globals" property in for customization?

from its default value from 0 to 1

This is the property I need to configure

http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.percentpositivepattern(VS.71).aspx

I just can't figure out how to do this! :(

This will remove the space between% and numbers.

How can I do this for the whole application?

Is it possible to add code to WebConfig or?

thanks

+1


a source to share


3 answers


You can change the format using the DataFormatString property on the BoundField:

<asp:BoundField DataField="YourPropertyName" DataFormatString="#0.##%" />

      



You can set the format to a custom format you like according to this article:

http://msdn.microsoft.com/en-us/library/0c899ak8.aspx

0


a source


You can change System.Globalization.CultureInfo.CurrentCulture to whatever you want at the beginning of each request (for example, in Application_BeginRequest in global.asax).



Of course, this will affect all values ​​displayed by your application, not just those displayed in the GridView.

+1


a source


I'm not sure if you can set it in a file web.config

, but what you can do is inherit from the grid view, set a property in the constructor, and use this new subclass.

0


a source







All Articles