Bind to multiple datasets using typed ADO.Net dataset with flexreport

Posted by: haim on 4 April 2021, 7:06 pm EST

    • Post Options:
    • Link

    Posted 4 April 2021, 7:06 pm EST

    I have created a flexreport in a winform application. The flexreport uses tables from an ado.net dataset that contains 5 tables. The flexreport only uses two of the tables and are defined in the report as Main and Datasource1.

    I have a form with a viewer and a button where the dataset gets filled and then I need to bind the tables to the report before I can view the report in the viewer.

    I can bind the Main table using this line of code:

     Me.C1FlexReport1.DataSource.Recordset = Dataset.table1
    

    I can’t figure out how to bind Dataset.table2 to the Datasource1 of the report in my code.

  • Posted 5 April 2021, 5:37 pm EST

    I figured it out. this works.

     Me.C1FlexReport1.DataSources(1).Recordset =dataset.table2
    

    also I had a problem with binding to data in subreports. I managed to do it this way (not extremely intuitive).

     Dim myrpt = CType(C1FlexReport1.Fields("NameofSubreportField"), C1.Win.FlexReport.SubreportField).Subreport
    myrpt.Datasource.Recordset = dataset.table3
    
  • Posted 5 April 2021, 6:30 pm EST

    Hi,

    Good to hear that you got the solution.

    As you code snippet shows, You can access the DataSourceCollection of FlexReport using the DataSources property and then change the specific data source according to your requirements.

    To access the sub-report field you can get the field from the FieldCollection using the Fields property of FlexReport and then typecast it to Subreport Field. Once you have the sub-report you can modify it according to your requirements.

    If you need any other help, please let us know.

    Regards.

    Avnish

Need extra support?

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

Learn More

Forum Channels