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

SL Viewer error handling

1 Answer 85 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 06 Sep 2012, 08:18 PM
Hi..
Can you provide a sample or direction of how to implement error handing on a report - rendered in the SL viewer.
thx again!

1 Answer, 1 is accepted

Sort by
0
Hrisi
Telerik team
answered on 12 Sep 2012, 12:31 PM
Hi Jon,

You can do it similar to the following code snippet:

public partial class MainPage : UserControl, IReportServiceClientFactory
{
    public MainPage()
    {
        InitializeComponent();
        this.ReportViewer1.ReportServiceClientFactory = this;
    }
 
    #region IReportServiceClientFactory Members
 
    ReportServiceClient IReportServiceClientFactory.Create(Uri remoteAddress)
    {
        ReportServiceClient client = new ReportServiceClient(remoteAddress);
        client.RenderAndCacheCompleted += new EventHandler<RenderAndCacheEventArgs>(client_RenderAndCacheCompleted);
        return client;
    }
 
    void client_RenderAndCacheCompleted(object sender, RenderAndCacheEventArgs e)
    {
        if (e.RenderingResult.HasError)
        {
            e.RenderingResult.Error = "My custom error message";
        }
    }
 
    #endregion
}

As you can see the MainPage contains a Silverlight ReportViewer. On other hand, the viewer uses IReportServiceClientFactory to get a reference to the proxy of the WCF Report service. In the example we simply return the default implementation which is the ReportServiceClient. ReportViewer uses the RenderAndCacheAsync method to render the report. You can hook to the RenderAndCacheComplete event in order to implement a custom error handing for a report.


All the best,
Hrisi
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
Jon
Top achievements
Rank 1
Answers by
Hrisi
Telerik team
Share this question
or