none
Error while adding datasource in SubReport RRS feed

  • Question

  • Hi,

    I am adding a subreport to main report(rdlc file). When there is no datasource added to Subreport(with basic textbox and not data)  pdf (which is the output of my report) is displayed properly. But when I add the datasource to mu Subreport, though pdf is displayed but the place where subreport has to be displayed shows the following error "Subreport could not be shown"

    Visual Studio Version is VS2008(.rdlc file).

    Note: I am just running it from my local environment.

    Any help would be greatly appreciated. I am new to Reports.

    Thanks,

    Vani

    Saturday, April 21, 2012 10:02 PM

All replies

  • Sunday, April 22, 2012 1:33 PM
  • Hi Gautam,

    I  created the sub report following the steps from the above link. I followed all the steps that was mentioned in the link. I got this error even then. So what I did was started from very basic thing first.

    > At first added the subreport with only one textbox and hard coded value. It worked.

    >Then I passed parameter to sub report. It worked.

    > The instance I added a datasource and ran it. I got this error again.

    I read in some link that an event handler has to added for the processing of Subreport. I am going to try it. But based on the link you gave, that doesnt seem necessary.

    Thanks for your reply.

    Vani

    Monday, April 23, 2012 2:51 PM
  • Vani:

    In the form code that houses the ReportViewer control, you need to add an event handler to process the subreport:
    LocalReport reportEngine = this.[NameOfYourReportViewer].LocalReport;
    reportEngine.SubreportProcessing += new SubreportProcessingEventHandler(this.processSubReport);

    Where the method (in this case, ‘processSubReport’) has a signature like this:
    private void processSubReport(object sender, SubreportProcessingEventArgs e) {}

    In this event, you pass the datasource for your subreport into the DataSources collection. In my example here I am passing in a typed DataTable from a typed DataSet, so I cast it as a generic DataTable type:
    e.DataSources.Add(new ReportDataSource("[NameYouGaveToTheReportDataSet]", (DataTable)this._myDataSet.MyDataTable));

    Hope this helps. 

    Kurt

    Wednesday, April 25, 2012 7:50 PM