views:

1093

answers:

1

I have an unbound XtraReport that has a subreport control which contains another report. I call "unbound" to a report that has the definition of the fields using a schema but not actually bound to any DataSet, I create a DataTable using a Data Access Layer and then pass that object to the DataSource property of the report.

So, I have the following code:

        // (...) Get the data from the db and fill a DataTable

        if (table.Rows.Count > 0)
        {
            report.DataSource = table;

            // (...) Get the data from the db and fill a DataTable for the subreport
            report.SubPurchaseOrder.Report.DataSource = tableSubReport;

            report.ShowPreviewDialog();
        }
        else
        {
            MessageBox.Show("No data to show.");
        }

But what I get using this approach is the subreport printed very oddly (take a look at the attached pdf, sorry it's in spanish but I think you get the idea).

I've read the DevExpress documentation and maybe I'm not getting the approach right, so my question to you is how to create a report that has one or more subreports but I have to provide the data to fill them using some process external to the reports, such as a Data Access Layer?

Please let me know if the question is not stated correctly or lacks of more info.

EDIT:

I uploaded a sample project with the report with problem here.

I've tried to use parameters of some kind. In the BeforePrint event of the subreport control, I tried:

((XRSubreport)sender).ReportSource.FilterString = "[IdPO_RO] = " + _idPurchaseOrder;

and

((XRSubreport)sender).ReportSource.Parameters["Id"].Value = _idPurchaseOrder;

Of course, for the second, I added a parameter and the filter string the same as the first but using the parameter.

+1  A: 

I could solve the problem.

The cause for this was that I was assigning to the wrong object. This line:

report.SubPurchaseOrder.Report.DataSource = tableSubReport;

should be:

report.SubPurchaseOrder.ReportSource.DataSource = tableSubReport;

So the brief explanation is that I was using another property to refer to the report contained in the subreport control (XRSubreport).

Sebastian