首先选择工具箱子报告,并提出要show.See图像波纹管
在子报表属性现在,右键点击并输入您的子报告名称。
现在你已经从你cs文件创建一个子报告,甚至处理,你加载你的报告那样:
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();
}
立即创建,甚至处理方法加载子报告的详细信息。
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)));
}
我认为它会适用于你。谢谢。
所有的报告都在同一个解决方案中吗?您是否尝试再次构建解决方案文件? – SouravA 2015-01-16 14:11:20