Telerik.ReportViewer.Html5.WebForms.ReportViewer and run-time connection string - how to?

2 posts, 0 answers
  1. Michael
    Michael avatar
    1 posts
    Member since:
    Aug 2018

    Posted 07 Dec 2018 Link to this post

    ReportViewer has property of the type ReportSource, which does not have connectionstring property, but has parameters

    How can I set connection string in runtime for the report that ReportViewer shows?

    C# sample will be much appreciated.

    Thanks!

     

     

  2. Todor
    Admin
    Todor avatar
    285 posts

    Posted 12 Dec 2018 Link to this post

    Hi Michael,

    I have answered the questions raised here in the support ticket you opened on the same topic. For the benefit of our community I will summarize the relevant information also here.

    The suggested approach for modifying DataSource connection string run time is to introduce a new Report Parameter in the report definition and assign the value of this parameter to the DataSource.ConnectionString property as explained in the Change Connection String dynamically through a report parameter KB article. The value of the Report Parameter can be passed from the viewer run time, and will be automatically assigned to the DataSource when processing the report.

    The Html5 Web Report Viewers exposes a ReportSource that is a client side Report Source, which is different from server side Report Source.
    The Html5 Report Viewer client side Report Source has two properties - report and parameters. The report is a string passed to the Report Resolver Resolve() method. The latter should be able to resolve this string to a valid server side Report Source. The values of the parameters in the parameters collection are automatically assigned to the Report Parameters with the same names. Note that client side Report Source properties vary according to the exact Html5 Web Viewer used (i.e. pure, MVC wrapper, Web Forms wrapper and Angular wrapper).

    An alternative approach for changing connections string dynamically that is suitable (although we do *not* recommend it) for Html5 Viewer can be found in Action NavigateToReport does not work after updating the Connection String dynamically in a Custom Report Resolver KB article. The ReportConnectionStringManager should be used in the Resolve() method of a Custom Report Resolver.

    Regards,
    Todor
    Progress 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