Hi Steven or Herb (or anyone),
I followed this discussion carefully - it seems to match my situation
very closely, but I did not get the success that Herb did at the end.
I'm working in Visual Web Developer 2005, using ASP.NET and VB 2005.
I am trying to create a report with a sub-report.
I first got a basic main report going - created a dataset based on
a simple query, and have no problem generating simple reports using
the ReportViewer control and a corresponding ObjectDataSourc e that
refers to the dataset tableadapter.
Next I created a "static" subreport (just to try walking before
crawling!). It does not depend on any dataset - it just provides
some static text. I include that as a sub-report in my main report
and it works fine.
Next I created a new dataset for the "real" sub-report. It takes a
single parameter - the key field from the "main" dataset. The aim is
that, when coupled with the main report, it will return the related
records in the sub-dataset for each record in the main report/dataset.
I test this sub-report by hard-coding a default value for the
parameter and it works fine as a stand-alone report, displaying the
correct related records from the sub-dataset for the hard-coded
parameter key value.
So... the last step is to put the sub-report into the main report. I
drop a subreport control into the main report's list control just
like I did with the static sub-report, right-click on it to open
the Properties dialog, choose the "real" sub-report (not the static
one this time) in the General tab, and finally set the parameter on
the Parameters tab (parameter name is SiteID, parameter value is
set from the drop-down to =Fields!SiteID. Value). This was my first
attempt and I thought it would be sufficient, but instead of getting
the sub-reports I get the error message:
Error: Subreport could not be shown.
That's when I found your recent discussion, and I tried what seemed to
be the 2 key issues in the solution: (1) adding some code-behind to
set the sub-datasource in the processingevent handler, and (2) adding
an <asp:ObjectData Sourcefor the sub-dataset to the aspx page. Having
done both of those, the error remains.
I set a breakpoint in the SetSubDataSourc e() handler - it never
fires, so I infer that the SubreportProces sing event is not being
raised(?).
I'm sure the devil is in the details, and I can provide those to
you as we go - this message is already too long, so I'll leave it
here for now and hope to hear from one of you soon... Thanks in
advance!
Chris
*** Sent via Developersdex
http://www.developersdex.com ***