Solved

gridview DataFormatString value truncated when iterating through the cells

Posted on 2010-11-26
2
744 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
2 Comments
 
LVL 12

Accepted Solution

by:
HugoHiasl earned 250 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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