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

Format textbox

3 Answers 690 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
rob mays
Top achievements
Rank 1
rob mays asked on 14 Jun 2007, 03:36 PM
I would like to know how and where I set the format for a textbox to display the date in 'dd/mm/yyyy' my report is displayed in a reportviewer on a web page. What will the TextBox1.Format = ""
string look like?

OK found it

3 Answers, 1 is accepted

Sort by
0
Hrisi
Telerik team
answered on 14 Jun 2007, 04:25 PM
Hello rob mays,

You can set Format property of the TextBox in тхе Property Grid to "{0:dd\/MM\/yyyy}"

 
Kind regards,
Hrisi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jason McIntyre
Top achievements
Rank 2
answered on 29 Sep 2007, 10:48 AM
Is it possible to format a date inside a textbox - as I append some text to the line ?

ie  =Now().ToString('{0:dd\/MM\/yyyy}') + " - Quote Number: " + Fields.quotenumber
0
Svetoslav
Telerik team
answered on 01 Oct 2007, 08:31 AM
Hello Jason McIntyre,

This is a valid expression and you can use it for your text boxes. With the Q2 2007 release there is a know issue with calling overloaded methods which is the case with DateTime.ToString(). This issue will be fixed in the upcoming service pack, due in two weeks.

Luckily, there are several workarounds - you can handle the TextBox's ItemDataBinding/Bound event or you can use a user function. We strongly encourage you to try the 2nd approach as we consider it to be superior.

User defined functions are new to Telerik Reporting Q2 2007 and are public static (Shared in Visual Basic.NET)  non-void (that return value) methods defined in your report classes. They can be used in any expression (item value, filters, grouping, sorting, conditional formatting) in the report they belong to. Once defined (and the project is compiled) at design time they appear in the Expression Builder which makes their use easier. Here is a sample function (in C#) that you can use to format the value of your text box:

class Report1 : Telerik.Reporting.Report
{
    ...
   
    public static string FormatQuoteNumber(int quoteNumber)
    {
        return string.Format("{0:dd/MM/yyyy} - Quote Number: {1}"
            , DateTime.Now
            , quoteNumber);
    }
    ...
}


Then for the textbox's value expression you can use this simpler expression:

=FormatQuoteNumber(Fields.quotenumber)

As you may already noticed the user defined functions extends the built-in functionality beyond the limits of its scripting engine and let you create advanced reports easier.

 
Kind regards,
Svetoslav
the Telerik team

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