Need Help Doing Master-Detail Report using a DataSet with Two Tables.

I am still new to fastreport (but thrilled).

I am using the designer control from within my winforms .NET application to try to design a master-detail report.

I have registed a data set that has two table in it. there is a parent->child relationship defined in the dataset for these two tables.

I can print the "parent" data from the initially created data band without problem. But I am having trouble printing the child data.

I am not sure what to do "next".

I tried adding a "detail" band "under" the initial (parent) data band, and I set the data source for that band to the child table. When I did that, I got all of the child data (for every parent) under the first parent, then got all of hte child data again under the 2nd parent. i.e. it seemed like the parent-child constraint was not being used.

In another attempt, I tried adding a "child" data band under the parent data band. When I did this, I could not find a way to set the child band's data source. That was a bad sign. When I printed this time I get the very first child data record, and only this record, under every single parent record.

Please help. Thanks.

Comments

  • customer -> contract = one to many

    contract -> job = one to many


  • Got it!. looking at your report in the designer I stumbled on the "filter" setting. Something I had read led me to beleinve that that sort of logic was set up automatically for me because I had that sort of relationship in the dataset.

    thanks

  • stgstg
    edited 1:14PM

    Hello!

    In the code, register the entire DataSet (report.RegisterData(ds)) and enable all tables and relationships (ds.Enabled = true, rel.Enabled = true).

    In the report designer, right-click the parent DataBand -> select Add Detail Data Band (it’s important that the detail DataBand be nested inside the parent DataBand, not added as a separate band right after it!).

    Double-click the nested detail DataBand and select the child table from the list the engine will automatically establish a Relation between the parent and child tables (when creating bands from code, be sure to explicitly specify detailBand.Relation = relation and relation.Enabled = true)

This discussion has been closed.