Last post Apr 14, 2011 12:10 PM by game_mc
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))
Apr 13, 2011 05:01 PM|game_mc|LINK
Here's an example of what I'd like the report to look like:
Users report example:
User ID User Name
Group ID Group Description
3 Basic User
Instead of the above, I get the following for UsersWithGroups:
Apr 14, 2011 12:10 PM|game_mc|LINK
Ok I figured this one out. Basically I was missing the addition of a "Filter" in the Row Group Properties on the subreport.
If anyone is curious, here's what I did:
On the main report (UsersWithGroups.rdlc) that contains the subreport, right click the subreport in the Report Designer > Click Parameters > Click Add > add a parameter named "UserID"
On the subreport (UserGroups.rdlc)
1. in the "Report Data" toolbox, right click Parameters > Add Parameter > add a parameter named "UserID"
2. on the tablix containing you report, right click the details row > Click Row Group > Click Group Properties > Click Filters > Add a filter for the UserID returned in the result set using the parameter you added in the previous