Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

DataFormatString is ignored on on some servers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jonefer - 29 Mar 2008 06:11 GMT
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 - 29 Mar 2008 10:28 GMT
> Is their any particular reason (server or design?) why the following line
> won't work on some servers?
[quoted text clipped - 21 lines]
> 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
Just Me - 29 Mar 2008 16:07 GMT
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.

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?
[quoted text clipped - 24 lines]
> 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 - 30 Mar 2008 03:45 GMT
now that --was helpful.  

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

> You say it works on VS on your Machine but not on the server is this correct
> ?
[quoted text clipped - 46 lines]
>
> HTH

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.