Solved

gridview DataFormatString value truncated when iterating through the cells

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now