1.添加子報表的數據源只能通過代碼方式,在函數方法 SubReportProcessingEventHandler中添加
this
.reportViewer.LocalReport.SubreportProcessing
+=
new
Microsoft.Reporting.WinForms.SubreportProcessingEventHandler(SubReportProcessingEventHandler);
private void SubReportProcessingEventHandler( object sender, Microsoft.Reporting.WinForms.SubreportProcessingEventArgs e)
{
e.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("dsOrder_订单明细", this.dsOrders.订单明细));
}
private void SubReportProcessingEventHandler( object sender, Microsoft.Reporting.WinForms.SubreportProcessingEventArgs e)
{
e.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("dsOrder_订单明细", this.dsOrders.订单明细));
}
2.不管是主報表還是子報表,在綁定數據源時代碼中的名稱和表或者列表屬性中的數據集名稱必須一致,否則會出現主報表無數據或者子報表無法顯示的問題。我就是沒注意這個問題浪費了1小時。