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

How to format Textbox Value field

1 Answer 719 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Cihad
Top achievements
Rank 1
Cihad asked on 07 May 2013, 07:52 AM
Hi,
I am using Telerik.Reporting.dll (version 5.1.11.928) and Telerik.ReportViewer.WinForms.dll (version 5.1.11.928) in Q2 Reporting 2011.

I have a column which calculates difference in minutes and I want to show them meaningful in my Telerik report.
Here is my column: sum(cast(datediff(second, IEC.CREATE_DATE, IEC.STATUS_DATE) as float) / 60) TotalSentMinutes

Here is some example values for this column: 
TotalSentMinutes
----------------------
2,15
0
1,36666666666667
92,1166666666667
902,383333333333 ... etc.

So, I want to show these values meaningfully by using Formatting in Textbox's value field. I wrote a method to show them formatted.

private string FormatMinutes(string number2)
        {
            if (number2 == "0")
                return "";

            int number = int.Parse(number2);
            string day = string.Empty;
            string hour = string.Empty;
            string minutes = string.Empty;
            string formatted = string.Empty;

            if (number >= 1440)
                day = (number / 1440).ToString();
            if (((number % 1440) / 60) > 0)
                hour = ((number % 1440) / 60).ToString();
            if ((number % 60) > 0)
                minutes = (number % 60).ToString();
            if (day != string.Empty)
                formatted += day + " day, ";
            if (hour != string.Empty)
                formatted += hour + " hour, ";
            if (minutes != string.Empty)
                formatted += minutes + " minutes";

            return formatted;
        }

I called this method in Textbox's value field like this: = IIf(Fields.SentCount = 0, 0, FormatMinutes(Fields.TotalSentMinutes))

However, I am getting error while formatting. Is it a syntax problem? Method calling problem? or should I substr values to get rid of commas in double values? How can I solve this problem?
Any suggestions?
Best,
Cihad

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 10 May 2013, 10:58 AM
Hi Cihad,

Please check the User Functions help article, elaborating on how to create a custom function and use it in expressions.

I hope this helps.

Regards,
Stef
the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

Tags
General Discussions
Asked by
Cihad
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or