How to change the C1Report's datasource in MVC application at RunTime

Posted by: kukemaster on 9 September 2017, 8:18 am EST

  • Posted 9 September 2017, 8:18 am EST

    Hi

    I see this blog, http://our.componentone.com/2013/03/20/using-reportviewer-in-mvc/ that show how to display C1Report in MVC application using C1ReportViewer

    In this blog using the design-time datasource, I want to set the datasource at runtime.

    How to implement this case.

    Thanks.

  • Posted 9 September 2017, 8:18 am EST

    Hi,

    You can assign a record set to the report.DataSource.Recordset property and then re-render the report by calling report.Render(). Does that help?

    Thanks.

  • Posted 9 September 2017, 8:18 am EST

    Thanks for your reply.

    I don’t how to access report.DataSource.Recordset property in this sample at http://our.componentone.com/samples/aspnet-usingreportviewerinmvc/

    Can you send me a complete sample base on this sample http://our.componentone.com/samples/aspnet-usingreportviewerinmvc/

  • Posted 9 September 2017, 8:18 am EST

    Hello Kukemaster,

    The easiest workaround here would be to create two separate, but identical report definitions that use two different connection strings. You could then add an extension to the name such as “SalesReport(DBOne)” and “SalesReport(DBTwo)” to differentiate them. These two report definition files will pull their data from the database defined in the connection string within the definition which would eliminate the need to swap out the datasource manually.

    Please let me know if this is a possibility for you, or if you would like me to send you an updated sample showing this being done.

    Regards,

    Justin

  • Posted 9 September 2017, 8:18 am EST

    Hi Justin Mack

    Thanks for your reply.

    I need to bind a DataSet to report’s DataSource at run-time, not change the connectionstring.

    I’m not familiar with Wijmo controls, could you send me a sample show how to bind DataSet to report’s DataSource at run-time.

  • Posted 6 July 2019, 12:56 am EST - Updated 29 September 2022, 10:48 am EST

    Hi did you make it work? I have exactly same requirement where I need to set the Datasource of a report at runtime for showing in Wijmo report viewer.

    Appeciate any help.

    THanks

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels