For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > March 2008 > DataFormatString is ignored on on some servers









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author DataFormatString is ignored on on some servers
jonefer

2008-03-29, 4:47 am

Is their any particular reason (server or design?) why the following line
won't work on some servers?

This is code within a Gridview control
<asp:BoundField DataField="Regional Target" DataFormatString="{0:#%}"
HeaderText="Regional Target"

This code works on my development machine VS Studio 2005 and Microsoft
Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727 SP1

What I am getting is unformated 'real' numbers... i.e. 0.638354978354978
instead of 64%.

Something to note is that font weighting like bold or underlining or
anti-aliasing is also not taking place on this server, although the correct
choice of font IS.

I have a hunch that there is a setting on a server that doesn't- allow such
formatting in favor of faster rendering therefore, less 'load' on the server?

If not, what causes the server to completely ignore the
DataFormatString="{0:#%}" ?

Stan

2008-03-29, 8:15 am

On 29 Mar, 05:11, jonefer <jone...@discussions.microsoft.com> wrote:
> Is their any particular reason (server or design?) why the following line
> won't work on some servers?
>
> This is code within a Gridview control
> <asp:BoundField DataField=3D"Regional Target" DataFormatString=3D"{0:#%}"
> HeaderText=3D"Regional Target"
>
> This code works on my development machine VS Studio 2005 and Microsoft
> Visual Studio 2005
> Version 8.0.50727.762 =A0(SP.050727-7600)
> Microsoft .NET Framework
> Version 2.0.50727 SP1
>
> What I am getting is unformated 'real' numbers... i.e. 0.638354978354978
> instead of 64%. =A0
>
> Something to note is that font weighting like bold or underlining =A0or
> anti-aliasing is also not taking place on this server, although the correc=

t
> choice of font IS. =A0
>
> I have a hunch that there is a setting on a server that doesn't- allow suc=

h
> formatting in favor of faster rendering therefore, less 'load' on the serv=

er?
>
> If not, what causes the server to completely ignore the
> DataFormatString=3D"{0:#%}" =A0 ?


Hi

I don't know why there should be any difference between the server to
the development machine (I doubt it has anything to do with
restrictive settings) but there is a standard numeric format specifier
for percentages in ASP.NET.

Try "{0:P0}" which will muliply by 100, round to the number of decimal
places specified (in this case 0) and add the % symbol.

HTH
Just Me

2008-03-29, 7:28 pm


You say it works on VS on your Machine but not on the server is this correct
?

Well, one think i can tell you is that there is a property for the
DataField's on the GridView called htmlEncode and if this is set to True,
then your format string will be ignored completely. It may be that there is
a difference between the aspx page on your local machine and the server,
this is the most likely difference.



"Stan" <google@philphall.me.uk> wrote in message
news:fa7f4d29-bbc8-44fa-9766-cc2613aabdff@i12g2000prf.googlegroups.com...
On 29 Mar, 05:11, jonefer <jone...@discussions.microsoft.com> wrote:
> Is their any particular reason (server or design?) why the following line
> won't work on some servers?
>
> This is code within a Gridview control
> <asp:BoundField DataField="Regional Target" DataFormatString="{0:#%}"
> HeaderText="Regional Target"
>
> This code works on my development machine VS Studio 2005 and Microsoft
> Visual Studio 2005
> Version 8.0.50727.762 (SP.050727-7600)
> Microsoft .NET Framework
> Version 2.0.50727 SP1
>
> What I am getting is unformated 'real' numbers... i.e. 0.638354978354978
> instead of 64%.
>
> Something to note is that font weighting like bold or underlining or
> anti-aliasing is also not taking place on this server, although the
> correct
> choice of font IS.
>
> I have a hunch that there is a setting on a server that doesn't- allow
> such
> formatting in favor of faster rendering therefore, less 'load' on the
> server?
>
> If not, what causes the server to completely ignore the
> DataFormatString="{0:#%}" ?


Hi

I don't know why there should be any difference between the server to
the development machine (I doubt it has anything to do with
restrictive settings) but there is a standard numeric format specifier
for percentages in ASP.NET.

Try "{0:P0}" which will muliply by 100, round to the number of decimal
places specified (in this case 0) and add the % symbol.

HTH


jonefer

2008-03-29, 10:39 pm

now that --was helpful.

Another thing that seems to work is to set the field as an item template.

"Just Me" wrote:

>
> You say it works on VS on your Machine but not on the server is this correct
> ?
>
> Well, one think i can tell you is that there is a property for the
> DataField's on the GridView called htmlEncode and if this is set to True,
> then your format string will be ignored completely. It may be that there is
> a difference between the aspx page on your local machine and the server,
> this is the most likely difference.
>
>
>
> "Stan" <google@philphall.me.uk> wrote in message
> news:fa7f4d29-bbc8-44fa-9766-cc2613aabdff@i12g2000prf.googlegroups.com...
> On 29 Mar, 05:11, jonefer <jone...@discussions.microsoft.com> wrote:
>
> Hi
>
> I don't know why there should be any difference between the server to
> the development machine (I doubt it has anything to do with
> restrictive settings) but there is a standard numeric format specifier
> for percentages in ASP.NET.
>
> Try "{0:P0}" which will muliply by 100, round to the number of decimal
> places specified (in this case 0) and add the % symbol.
>
> HTH
>
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com