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

Expression as Format value

2 Answers 555 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Scott Waye
Top achievements
Rank 2
Veteran
Iron
Scott Waye asked on 21 Jun 2015, 04:17 PM

Hi,  Using a textbox in the report to display a date, we can use {0:d} to get a short date, e.g. 01/02/2015, but in our app we allow the user to specify their own format string on a per user basis, so we pass that in as a parameter (typically to get an even shorter format, e.g. 01/02/15).  In the Format field for a TextBox is it possible to use an expression, e.g. =Parameters.dateFormat.Value ? 

 As background we are evaluating converting from SSRS to Telerik reporting, and in SSRS this is possible by just using Parameters.dateFormat.Value in the Format field, but in Telerik this does not seem to work.  I can see that this is possible to do in the Value field using an expression on the lines

 =sFields.startEventDtm.ToString(Parameters.dateFormat.Value)

 But this will fail with a null reference exception of startEventDtm is null, whereas using  a format string will handle the null neatly.

2 Answers, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 23 Jun 2015, 02:09 PM
Hi Scott,

You can use a binding to the TextBox.Format property which expects a string value representing format e.g., {0:p2}.where the TextBox.Value is evaluated as a numeric value.

textBox1.Value="=123";
 
//binding
Path: Format
Expression: =Parameters.Parameter1.Value
 
//possible values for the report parameters
{0:N2}
{0:p2}


I hope the provided information is helpful.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Scott Waye
Top achievements
Rank 2
Veteran
Iron
answered on 23 Jun 2015, 08:27 PM
Thanks, that's the answer.
Tags
General Discussions
Asked by
Scott Waye
Top achievements
Rank 2
Veteran
Iron
Answers by
Stef
Telerik team
Scott Waye
Top achievements
Rank 2
Veteran
Iron
Share this question
or