This is a migrated thread and some comments may be shown as answers.

DataFormatString with zeros

3 Answers 292 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Attila
Top achievements
Rank 1
Attila asked on 11 Sep 2014, 12:01 PM
Hi,

I would like to use DataFormatString in my radgrid to convert numbers:
DataFormatString="{0:# ### ###}"
It's working perfectly with numbers like 54210 = 54 210.
But it's not working with zeros (0).

Also what can I do with negative numbers? Now it's like -54210 = - 54 210. I want it to be -54 210.

How can I fix this?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 16 Sep 2014, 10:59 AM
Hello Attila,

Can you please provide us several more samples demonstrating the desired formatting? Thus, we will try to come up with viable solution to match your scenario using the following resources:
http://msdn.microsoft.com/en-us/library/dwhawy9k%28v=vs.110%29.aspx
http://msdn.microsoft.com/en-us/library/0c899ak8%28v=vs.110%29.aspx


Looking forward to your reply.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Attila
Top achievements
Rank 1
answered on 19 Sep 2014, 08:48 AM
Hello Eyup,

Here are some samples:
I want a seperation in every thousand.
So
123 = 123
1234 = 1 234
12345 = 12 345
123456 = 123 456
-12345= -12 345
-123456 = -123 456
and 0 = 0

I got nothing for zeros and for "-123456" i get "- 123 456"

Regards,
Attila
0
Konstantin Dikov
Telerik team
answered on 24 Sep 2014, 08:42 AM
Hi Atilla,

RadGrid uses the String.Format method for applying the DataFormatString and the issues that you are experiencing are related to the way that you current format is applied. You test the String.Format method and you will see the following result with the format you are specifying:
  • string.Format("{0:# ### ###}", 0) = " "
  • string.Format("{0:# ### ###}", -54654) = "- 54 654"
    string.Format("{0:# ### ###}", -54654)string.Format("{0:# ### ###}", -54654) = "- 54 654"

Since the result you are observing are not related to our controls, please refer to the MSDN article for custom formats and change your format accordingly, so it could fit your exact requirements:

Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Attila
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Attila
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or