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

Does a Field exist?

1 Answer 299 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 01 Aug 2012, 03:10 PM
I have a textbox bound to "Field.A".
The problem is that sometimes "Field.A" does not exist and in these cases I need to bind the textbox to "Field.B".

It was recommended that I use a user function :

public static String ResolveField()
{
string s = new string();

// ????
// Check if Field.A exists
// if yes then s = Field.A
// else s = FieldB

return s;
}


How can I check to see if a field exists without an exception?

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 03 Aug 2012, 09:06 AM
Hello Paul,

Define ""Field.A" does not exist". In your example "A" is the name of your datasource column, so it should always exist. Do you mean that it might return null or a value that you want to replace with another one? You can accomplish this by using the built-in Functions like IsNull(expression, ReplacementValue) or IIf(expression, ReturnedIfTrue, ReturnedIfFalse). You can of course use an User Functions as well and handle any checks inside it with the help of your preferred language (C#, VB.NET). You would have to change the function signature to have the field as argument, and the TextBox expression should be:

= ResolveField(Fields.A)

Regards,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

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