Solved

gridview DataFormatString value truncated when iterating through the cells

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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 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