Solved

gridview DataFormatString value truncated when iterating through the cells

Posted on 2010-11-26
2
743 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 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