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

Problem with #Y{#,#}

2 Answers 56 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Adam Hubble
Top achievements
Rank 1
Adam Hubble asked on 20 Apr 2009, 08:47 AM
Hi, I'm trying to do the following in RadChart itemdatabound event:

e.seriesItem.Label.TextBlock.Text = String.Format("#Y{#,#}", e.DataItem("mostviewed").ToString())  & " - " & e.DataItem("percentVal")

This causes the page to throw an error, saying that the input string is not in the correct format. If I change string.format to use "#Y", the page runs fine (but obviously my number has no comma formatting!).

I have used "#Y{#,#} with RadChart before to set defaultlabelvalue and it works as expected there so I am confused as to why the above does not work.

Thanks,
Matt

2 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Milev
Telerik team
answered on 23 Apr 2009, 06:01 AM
Hi Matt Davis,

The "#Y{#,#}" label format expression you are using is specific to RadChart and as such it is only understood by RadChart. You seem to be passing the expression to String.Format() method which is native for the framework and does not understand RadChart specific format expressions. 

Please try using this format: "{0:#,#} - {1:p0}". Also, make sure you pass the two arguments to string format as numeric values:

e.seriesItem.Label.TextBlock.Text = String.Format("{0:#,#} - {1:p0}", e.DataItem("mostviewed"),  e.DataItem("percentVal"))

All the best,
Vladimir Milev
0
Adam Hubble
Top achievements
Rank 1
answered on 23 Apr 2009, 08:09 AM
Thanks Vladimir
Tags
Chart (Obsolete)
Asked by
Adam Hubble
Top achievements
Rank 1
Answers by
Vladimir Milev
Telerik team
Adam Hubble
Top achievements
Rank 1
Share this question
or