Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

gridview DataFormatString value truncated when iterating through the cells

Posted on 2010-11-26
2
Medium Priority
?
750 Views
Last Modified: 2012-05-10
Hi all,
Im getting a very weird thing happening when I use a DataFormatString on a gridview boundfield.
I have these settings:
<asp:BoundField  ItemStyle-Width="75px" HeaderText="Exports" DataField="Exports" DataFormatString="{0:###,##0}"></asp:BoundField>

This displays the figures correctly no the web page e.g. 7,403. Exports is a decimal.
However, Im trying to export this to PDF and whenever I try and loop through the cells I get a trucated figure : 7,40 instead.
string strValue = Server.HtmlDecode(gvPipelines.Rows[0].Cells[1].Text);

It doesnt happen when I remove the date format string.
Does anyone know why this would happen?
Thanks!

 
0
Comment
Question by:enterpriseireland
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
HugoHiasl earned 1000 total points
ID: 34217615
This could be a culture problem.

I assume it is treating your , as decimal separator and not as thousands separator. this make 7.403 out of your 7,403.

This could be truncated to 7,40 because this is often a standard precision for numeric values especially if it could show currencies.

Which culture are you using? Which regional settings does the client have? Which does the server have?
0
 

Author Comment

by:enterpriseireland
ID: 34217671
spot on. I added System.Globalization.NumberFormatInfo settings in my code behind and formatted the figure there instead of on the gridview and it worked!
:)
Thanks a million!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question