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

Binding PageBreak Property

1 Answer 211 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Keith Knight
Top achievements
Rank 1
Keith Knight asked on 09 Sep 2011, 04:49 AM
From the property window in the designer, I am attempting to set the Binding expression for PageBreak based on the existing of a databound field.

I would expect that it is something like:
PageBreak = !string.IsNullOrEmptyOrWhitespace(Field.MyTextField) ? PageBreak.Before : PageBreak.None;

Can this be done without writing actual code behind on the report?

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 12 Sep 2011, 04:43 PM
Hello Keith Knight,

When Bindings are used the expression should be evaluated to an object of type appropriate for the target property. In case of PageBreak you will need an user functions to perform appropriate type conversions. Check out the following code snippet and sample binding:

public static PageBreak ConvertPageBreak(string pageBreak)
{
    if (string.Equals(pageBreak, "before", StringComparison.InvariantCultureIgnoreCase))
    {
        return PageBreak.Before;
    }
    return PageBreak.None;
}
Once you add the user function and build the project, you can utilize it in multiple expressions without any further coding.
Property path  Expression 
 PageBreak 
=IIF(Fields.MyTextField is null OR Fields.MyTextField="", ConvertPageBreak("none"), ConvertPageBreak("before"))


Kind regards,
Peter
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Keith Knight
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or