Apr 13, 2011 01:23 PM|game_mc|LINK
I've racked my brain trying to figure this out. Hopefully someone can help.
What I am trying to achieve is a User report with the option of showing the Groups the Users belong to.
- Users (accepts UserID as a parameter; if UserID is empty, pulls all users)
- Groups (same parameter as above; I realize I could have used the same stored proc but this is where I am after trial and error)
- Users (main report)
- UserGroups (sub report; accepts a parameter for UserID)
- UsersWithGroups (main report w/ sub report; on the SubReport object, I've added a parameter for UserID)
The Users report works great. It pulls a single user or all users depending on the web user's selection.
The UsersWithGroups report works if the web user selects a single user to display. But when the web user selects all users, the subreport shows all groups for all users.
Protected Sub RunReport()
Dim dtUserData As New DataTable
ReportViewer1.ProcessingMode = ProcessingMode.Local
If chkShowDetail.Checked Then 'Show Group Subreport
ReportViewer1.LocalReport.ReportPath = "UserReportWithGroups.rdlc"
AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf LocalReport_SubreportProcessing
ReportViewer1.LocalReport.ReportPath = "UserReport.rdlc"
dtUserData = LoadUserData()
ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Users", dtUserData))
ReportViewer1.LocalReport.SetParameters(New ReportParameter("ReportName", lblReportName.Text, False))
Private Sub LocalReport_SubreportProcessing(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
If dtUserDetailsData Is Nothing Then
dtUserDetailsData = LoadUserGroupData()
e.DataSources.Add(New ReportDataSource("UserGroups", dtUserDetailsData))