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

null string concatenation

3 Answers 329 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
MiddleTommy
Top achievements
Rank 1
MiddleTommy asked on 22 Feb 2011, 09:56 PM
When building expressions in the designer and there is a null string the resulting string is null

type = null
size = "5x5x1/2"
length = "5 feet"

expression
=Fields.type + " " + Fields.size + " " + Fields.grade

resulting value is null in report textbox

It sure would be nice to Directly support string.Format(string, params object[] items) in expressions.
My guess is the params is not easily translated. from an expression.

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 23 Feb 2011, 04:01 PM
Hello MiddleTommy,

You can handle null values with the built-in IsNull Function. Generally formatting any string can be easily achieves with Member Access i.e. ToString('your_format'). Another approach is creating User Functions where you can format the field value using String.Format

Kind regards,
Steve
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
1
MiddleTommy
Top achievements
Rank 1
answered on 23 Feb 2011, 04:55 PM
I got the work around OK
I wrote a user function to handle the string formatting. But I had to specify the exact amount of arguments (no biggie really)
However my point was

string str1 = null;
string str2 = "Hi Mom";

In Telerik.Reports.Expression
str1 + str2 = null

In C#
str1 + str2 = "Hi Mom"

It is very tedious to check IsNull on every string in a report to assure proper output.
0
Steve
Telerik team
answered on 24 Feb 2011, 05:20 PM
Hi MiddleTommy,

This behavior is by design and behaves similarly to concatenation in SQL. NULL is an unknown
value and the result would also be unknown value.

Greetings,
Steve
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
MiddleTommy
Top achievements
Rank 1
Answers by
Steve
Telerik team
MiddleTommy
Top achievements
Rank 1
Share this question
or