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

User functions

2 Answers 228 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yoni Dagan
Top achievements
Rank 1
Yoni Dagan asked on 19 Jun 2008, 05:10 AM

On my report I have text box - Age(). How I can to run below function:

public

string CalculateAge()

{

DateTime BirthDate = DateTime.Now;

int years = DateTime.Now.Year - BirthDate.Year;

// subtract another year if we're before the

 

// birth day in the current year

 

if ((DateTime.Now.Month < BirthDate.Month && (BirthDate.Month - DateTime.Now.Month) >= 6))

years--;

return years.ToString();

}

as User functions for value the text box

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 19 Jun 2008, 12:39 PM
Hi Sergey,

User functions are public static methods that always return a value and should always be a member of the respective report class. So your method should be:

 public static string CalculateAge(int years)
        {

        }

After you rebuild your report class, you would be able to see your user function in the "Edit Expression" builder, where you could choose the field to bind to.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Yoni Dagan
Top achievements
Rank 1
answered on 19 Jun 2008, 12:41 PM
Thank you!
Tags
General Discussions
Asked by
Yoni Dagan
Top achievements
Rank 1
Answers by
Steve
Telerik team
Yoni Dagan
Top achievements
Rank 1
Share this question
or