How to return error(string) from dynamic report?

5 posts, 0 answers
  1. Frank
    Frank avatar
    86 posts
    Member since:
    Mar 2012

    Posted 25 May Link to this post

    Hi

    I have a situation where i will be generating a bunch of reports that will be dynamically created, converted into pdf files and stored in a folder on the local computer.

    The reports are generated in the loop and the data for the report is dynamically accessed through the middle layer. (Report is not connected directly to the database.) I will be accessing the middle layer from the report based on the parameters that were sent from the front end (WinForm). 

    There are many chances for me to get the input wrong or the data is not right. I am populating a string "error" with the appropriate error message which needs to return to the winform, which in turn will save the information and keep looping through the sequence to create further reports. 

    I couldn't find the way to access the error information, upon returning to winform. (BTW these dynamic reports are never displayed on the form. ) 

    Please help me find a way to access error field from the calling form.

    Thanks.

  2. Frank
    Frank avatar
    86 posts
    Member since:
    Mar 2012

    Posted 26 May Link to this post

    Can someone please point me in the right direction? Thanks.
  3. DevCraft banner
  4. Stef
    Admin
    Stef avatar
    3042 posts

    Posted 27 May Link to this post

    Hello Frank,

    The ReportProcessor has an Error event that can be used for catching errors during the processing. You can also subscribe each Telerik.Reporting.Report instance to its Error event in order to log issues in the report and to cancel the further processing, if needed.


    On a side note, you can verify dynamically generated reports by serializing their settings in XML (TRDX files) - Serialize Report Definition to an XML file. The result can be checked in the Standalone Report Designer tool.


    I hope this 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
  5. Frank
    Frank avatar
    86 posts
    Member since:
    Mar 2012

    Posted 27 May in reply to Stef Link to this post

    Thank you.

    What is the best way to set the datasource to the report programmatically.

    From with in the event Report_NeedDataSource(object sender, EventArgs e)

    or from the winform?  I also have many subreports that uses the Lits<objects> as their datasource.

  6. Stef
    Admin
    Stef avatar
    3042 posts

    Posted 31 May Link to this post

    Hello Frank,

    You can use the report's NeedDataSource - Using Report Events, or you can update the items before processing the report e.g.:
    //retrieve an instance of the report     
                var  reportInstance = new MyReport();
           
                //change the report's DataSource settings
                (reportInstance.DataSource as Telerik.Reporting.SqlDataSource).ConnectionString = "new string here";
            
                //change a nested data item's DataSource
                ((reportInstance.Items.Find("table1",true)[0] as Telerik.Reporting.Table).DataSource =GetStoredOnTheServerData();
                //set report parameters values
                 reportInstance.ReportParameters["UserId"].Value = GetUserId();
             
                 var IRS = new InstanceReportSource { ReportDocument = reportInstance };

    If you prefer using expressions, please check the data-binding approaches suggested in the  How to bind Sub Report to Main Report's Data KB article.



    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
Back to Top
DevCraft banner