Groups | Blog | Home
all groups > dotnet windows forms databinding > november 2006 >

dotnet windows forms databinding : ReportViewer databinding


AlBruAn
11/20/2006 6:39:02 AM
Hi,

I have several business objects I'm needing to run reports against. I
haven't had any problems creating simple reports going against one or two
objects, but I have a summary report I need to generate and it's driving me
nuts. At the top level, I have an Estimate object which contains a
Departments collection of Department objects, each of which contains a
Drawings collection of Drawing objects. A simple tree of these objects is:

Estimate
|--- Departments
|--- Department
|--- Drawings
|--- Drawing

There are various types of drawings contained in the Drawings collection:
CADD-generated, existing manually-drawn, etc. So, the report needs to loop
through each department and loop through each drawing within that department
to gather the data for the report.

To create the data sources for the report, I'm trying to use the following:
Estimate est = new Estimate.GetEstimate(estimateNumber);
Departments estDept = est.Department;
Drawings estDwgs = estDept.Drawing;

I have three ProjectBindingSource objects using the above as follows:
estBindingSource.DataSource = est;
estDeptBindingSource.DataSource = estDept;
estDwgsBindingSource.DataSource = estDwgs;

Programmatically, I'm able to loop through the objects as desired (I have to
alter the last statement a bit...such as, Drawings estDwg =
estDept[i].Drawings), but I can't get the report to work correctly. It will
loop through the Departments collection and return the information from the
Department, but it only pulls the Drawing information for the first
Department and then displays it for all subsequent Department objects.

I realize this is rather limited info, but can anyone please point me in the
right direction as to how to format my summary report??? Many thanks!
Bart Mermuys
11/20/2006 9:53:26 PM
Hi,

[quoted text, click to view]

But, according to your object model, Departments doesn't have Drawings,
Department does. I'm also a little confused about a property in singular
form that returns a list.

[quoted text, click to view]

Firstly i don't know much about Reports. But WinForms uses BindingSource's
too and there you would link the BindingSource's to each other, so that they
navigate in a parent-child fashion.

estBindingSource.DataSource = new Estimate.GetEstimate(estimateNumber);

estDeptBindingSource.DataSource = estBindingSource;
estDeptBindingSource.DataMember = "Departments"; // property on Estimate
that returns the Departments

estDwgsBindingSource.DataSource = estDeptBindingSource;
estDwgsBindingSource.DataSource = "Drawings"; // property on Department
that returns Drawings


Not sure if this helps with reports...

HTH,
Greetings


[quoted text, click to view]

AddThis Social Bookmark Button