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

Binding Expression using aggregate SUM() with String.Format

3 Answers 290 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jafin
Top achievements
Rank 2
Jafin asked on 28 May 2007, 04:52 AM
I have a groupFooter textbox which I am trying to display the Total amount of money for a group.

I cannot figure out the expression value to set to get it to format correct.  I'd like to use ToString('$#,0.') and this is what I have but it is giving a IFormat error.

textbox.Value = CINT(SUM(FundingValue)).ToString('$#,0.');

gives: Object of type System.String cannot be converted to System.IFormatProvider.  (guessing CINT cast didnt work?)

textbox.Value = SUM(FundingValue).ToString('$#,0.');
gives Cannot interpret token '.' at position x.

FundingValue is of type decimal.

Any help appreciated.

Regards,
Jason


3 Answers, 1 is accepted

Sort by
0
Jafin
Top achievements
Rank 2
answered on 28 May 2007, 06:33 AM
It looks like I can use the workaround found in http://www.telerik.com/community/forums/thread/b311D-mdkek.aspx

0
Jafin
Top achievements
Rank 2
answered on 28 May 2007, 07:05 AM
Doh!

textbox.Value = CINT(SUM(FundingValue)) 
textbox.Format = "{0:$#,0.}";  
Achieved what I required.

Dear Telerik, it may help if the documentation page for TextBox Class : Format Property had an example/comment explaining the syntax required is the same as String.Format() style for the TextBox Format Property?

It's listed on the TextBox Class page but not the TextBox.Format page in help.



0
Svetoslav
Telerik team
answered on 28 May 2007, 09:54 AM
Hello Jafin,

It seems that the actual problem is in the fact that the expression engine has found a wrong Int32.ToString() overload. Instead of using Int32.ToString(String) it used Int32.ToString(IFormatProvider). The workaround you've came across should serve your needs, but I'm afraid that you can use it only to format the text of the TextBox. We've logged this issue and fix it as soon as possible. The documentation will be updated with this where needed.

Thanks for the feedback and for sharing your findings.


Sincerely yours,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Jafin
Top achievements
Rank 2
Answers by
Jafin
Top achievements
Rank 2
Svetoslav
Telerik team
Share this question
or