I am working on RDLC report On VS2012
When I am trying add a parameter on my Sub report then my report is not working and I am getting this error “Error: Sub report could not be shown.”
And after adding parameter this event LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e) is not even called.
I realize that I'm late to the party here but this question came up during my searches so maybe this will help someone. I finally got sup reports working in my main report of my web application.
in Page_Load I added
ReportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(SetSubDataSource);
this.ReportViewer1.LocalReport.Refresh();
then in I added the event
public void SetSubDataSource(object sender, SubreportProcessingEventArgs e)
{
var report = ((LocalReport)sender).DataSources[0];
var tableid = e.Parameters["tableId"].Values[0];
ObjectDataSource2.SelectParameters[0].DefaultValue = tableid;
e.DataSources.Add(new ReportDataSource("DataSet2", ObjectDataSource2));
}
You'll also need to make sure that your main report's sub report has the correctly defined parameter and data as well as the sub report itself. This works for me using a stored procedure with one parameter but I assume it's easy to add additional params once this is firing correctly. I also set the general options of my sub report data type to Integer (the type my sproc was expecting) and to allow nulls as well as set the default value as "Specify values" and left it as (Null).
Things finally started working when I added
<SelectParameters>
<asp:Parameter Name="tableId" Type="Int32" />
</SelectParameters>
inside the ObjectDataSource2 node of my sub reports data source object, your mileage may vary.