Could not select subreport – .rdlc – VS 2010

rdlcreporting-servicessubreportvisual studio 2010

I had created many reports with VS 2008. Now starting with VS 2010 for new requirement. Please note I am using .rdlc report

  • I could add subreport control to the report but could not select the available reports. There is no browse button or a dropdown to choose the available .rdlc report.

  • When I manually type the report name, the reportviewer doesnt show up any subreport. I dont see any error message on the 'Output' window either.

How do I use subreport with VS 2010? Am I missing anything? Any help is appreciated.

I have SQL 2005/2008 (report services installed), VS 2008, VS 2010 installed on the same PC.

Best Answer

First select sub report from Toolbox and put where you want to show.See the image bellow enter image description here
Now right click on sub report properties and type your sub report name . enter image description here

Now You have to create a sub report even handler in your .cs file from where you load your report like that:

public Ctor()
{
    string path = HttpContext.Current.Server.MapPath("Your Report path");
    ReportViewer1.Reset(); //important
    ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
    ReportViewer1.LocalReport.SubreportProcessing += Process_Subreport;
    LocalReport objReport = ReportViewer1.LocalReport;
    objReport.ReportPath = path;

    // Add Parameter If you need 
    List<ReportParameter> parameters = new List<ReportParameter>();
    parameters.Add(new ReportParameter("Name", Value));
    ReportViewer1.LocalReport.SetParameters(parameters);
    ReportViewer1.ShowParameterPrompts = false;
    ReportViewer1.ShowPromptAreaButton = false;
    ReportViewer1.LocalReport.Refresh();

    //Add Datasourdce
    ReportDataSource reportDataSource = new ReportDataSource();
    reportDataSource.Name = "Datasource Name Used due to report design";
    reportDataSource.Value = DataSourceValue;
    objReport.DataSources.Add(reportDataSource);
    objReport.Refresh();
}

Now Create Even Handler Method to load sub report details.

private void Process_Subreport(object sender, SubreportProcessingEventArgs e)
{
  //You can get parameter from main report 
  int paramname = int.Parse(e.Parameters[0].Values[0].ToString());
  //You can also add parameter in sub report if you  need like main report

  //Now add sub report data source     
   e.DataSources.Add(new ReportDataSource("DataSource Name",DataSourceValue)));
 }

I think it will be works for you.Thank you.