我的子报表在主报表的每个单元格中显示所有结果
My subreport is displaying all the result in each cell in the Main Report
我确实有名为 MainReport.rdlc 和 SubReport.rdlc.
的 RDLC 文件
Subreport.rdlc(很明显,充当我的子报表)。
我能够在主 Table 中显示子报表的详细信息。但问题是子报表在我的子报表中显示每一行的所有数据
我要的是这个:
但实际情况是这样的:
MainReport上的数据集查询
Select DISTINCT tblMain.ID_Num, tblMain.fldDate,Scope.Description,tblMain.Accomplishment,Rating.fldQuality, Rating.fldQuantity, Rating.fldAccuracy from tblMain
JOIN tblScope as SCOPE on tblMain.Scope = Scope.Id
LEFT JOIN tblRatings as Rating on tblMain.RatingRefCode = Rating.ScopeCode
where tblMain.ID_Num = @RefNo AND fldDate between @Start and @End
Group By tblMain.ID_Num, tblMain.fldDate,Scope.Description,tblMain.Accomplishment,Rating.fldQuality, Rating.fldQuantity, Rating.fldAccuracy
这是子报表上的数据集查询
Select DISTINCT tblMain.ID_Num, tblMain.fldDate,Scope.Description,tblMain.Accomplishment from tblMain
JOIN tblScope as SCOPE on tblMain.Scope = Scope.Id
LEFT JOIN tblRatings as Rating on tblMain.RatingRefCode = Rating.ScopeCode
where tblMain.ID_Num = @RefNo AND fldDate between @Start and @End
Group By tblMain.ID_Num, tblMain.fldDate,Scope.Description,tblMain.Accomplishment
您似乎没有设置子报表参数。
在MainReport.rdlc:
- 右键单击子报表 > 子报表属性 > 参数
- 设置名称为
ScopeParameter
且值等于数据集中范围字段的新参数(例如 [ScopeId]
)
在Subreport.rdlc:
- 设置名称为
ScopeParameter
的新参数
- 在您的 Tablix 或 Tablix 组中使用
[ScopeId] = @ScopeParameter
定义新过滤器
对于大量数据,使用 SubreportProcessingHandler
事件过滤子报表中的数据似乎比在 Tablix 或 Tablix Group 中设置过滤器更快。
Private Sub SubreportProcessingHandler(sender As Object, e As SubreportProcessingEventArgs)
Dim intScope As Integer = CInt(e.Parameters.Item("ScopeParameter").Values(0))
Dim dvYourDataView As New DataView(Me.dsYourDataset.Tables(0))
dvYourDataView.RowFilter = "ScopeId = " & intIdScope
e.DataSources.Add(New ReportDataSource("YourReportDataSourceName", dvYourDataView.ToTable("YourReportDataSourceName")))
End Sub
我确实有名为 MainReport.rdlc 和 SubReport.rdlc.
的 RDLC 文件Subreport.rdlc(很明显,充当我的子报表)。
我能够在主 Table 中显示子报表的详细信息。但问题是子报表在我的子报表中显示每一行的所有数据
我要的是这个:
但实际情况是这样的:
MainReport上的数据集查询
Select DISTINCT tblMain.ID_Num, tblMain.fldDate,Scope.Description,tblMain.Accomplishment,Rating.fldQuality, Rating.fldQuantity, Rating.fldAccuracy from tblMain
JOIN tblScope as SCOPE on tblMain.Scope = Scope.Id
LEFT JOIN tblRatings as Rating on tblMain.RatingRefCode = Rating.ScopeCode
where tblMain.ID_Num = @RefNo AND fldDate between @Start and @End
Group By tblMain.ID_Num, tblMain.fldDate,Scope.Description,tblMain.Accomplishment,Rating.fldQuality, Rating.fldQuantity, Rating.fldAccuracy
这是子报表上的数据集查询
Select DISTINCT tblMain.ID_Num, tblMain.fldDate,Scope.Description,tblMain.Accomplishment from tblMain
JOIN tblScope as SCOPE on tblMain.Scope = Scope.Id
LEFT JOIN tblRatings as Rating on tblMain.RatingRefCode = Rating.ScopeCode
where tblMain.ID_Num = @RefNo AND fldDate between @Start and @End
Group By tblMain.ID_Num, tblMain.fldDate,Scope.Description,tblMain.Accomplishment
您似乎没有设置子报表参数。
在MainReport.rdlc:
- 右键单击子报表 > 子报表属性 > 参数
- 设置名称为
ScopeParameter
且值等于数据集中范围字段的新参数(例如[ScopeId]
)
在Subreport.rdlc:
- 设置名称为
ScopeParameter
的新参数
- 在您的 Tablix 或 Tablix 组中使用
[ScopeId] = @ScopeParameter
定义新过滤器
对于大量数据,使用 SubreportProcessingHandler
事件过滤子报表中的数据似乎比在 Tablix 或 Tablix Group 中设置过滤器更快。
Private Sub SubreportProcessingHandler(sender As Object, e As SubreportProcessingEventArgs)
Dim intScope As Integer = CInt(e.Parameters.Item("ScopeParameter").Values(0))
Dim dvYourDataView As New DataView(Me.dsYourDataset.Tables(0))
dvYourDataView.RowFilter = "ScopeId = " & intIdScope
e.DataSources.Add(New ReportDataSource("YourReportDataSourceName", dvYourDataView.ToTable("YourReportDataSourceName")))
End Sub