Solved

RDLC passing parameters from main report to subreport

Posted on 2016-08-03
4
31 Views
Last Modified: 2016-08-16
I am trying to develop a report with Report Viewer in VS 2013 with a subreport. Now both the main data source and the sub report data source are stored procedures with parameters. I can get my main report to run with getting parameters from the controls on the form. From my testing I can get the parameter that needs passed from my main report to my subreport but it does not filter the results out based on that parameter. I am at a complete lost.

Here are my two data sources, ObjectDataSource3 is my main data source and ObjectDataSource4 is my sub report data source:

        <asp:ObjectDataSource ID="ObjectDataSource3" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="FS2.FS2_v2DataSetTableAdapters.spselNonCompliantTableAdapter" OnSelecting="ObjectDataSource3_Selecting">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlProjectName" Name="ProjectId" PropertyName="SelectedValue" Type="Int32" />
                <asp:ControlParameter ControlID="txtRoute" Name="Route" PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="txtZone" Name="Zone" PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="txtNecoSection" Name="NecoSection" PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="ListBox1" Name="LogTypeInclude" PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>

        <asp:ObjectDataSource ID="ObjectDataSource4" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="FS2.FS2_v2DataSetTableAdapters.spselSubRepNonCompliantEventsTableAdapter">
            <SelectParameters>
                <asp:Parameter DefaultValue="" Name="AccountId" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>

protected void Button1_Click(object sender, EventArgs e)
        {


ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetSubDataSource);
            
            ReportViewer1.LocalReport.SetParameters(reportParameterCollection);

        }

        public void SetSubDataSource(object sender, SubreportProcessingEventArgs e)
        {
e.DataSources.Add(new ReportDataSource("FS2DS", "ObjectDataSource4"));

        }

Open in new window


I have my in my main report rdlc the sub report with its name properly spelled with a parameter to be passed. If I give the sub report a default parameter from the form, it will run but will only use that parameter even though if I display the parameter being passed from the main report it is different.
0
Comment
Question by:nmiller61
  • 3
4 Comments
 

Author Comment

by:nmiller61
ID: 41741012
Looking more at it. My main problem is how do I tied the AccountId from the Main Report Data Set to my Sub Report Data Set?
0
 
LVL 2

Expert Comment

by:Charles
ID: 41752205
Hi,

Go to main report design page , right click on sub report and select properties, Go to parameter tab, Add the parameter, Hope missed this one alone, This supposed to filter record
0
 

Accepted Solution

by:
nmiller61 earned 0 total points
ID: 41752237
Hi Charles. That is one piece of the puzzle but I was actually able to work through the issue on an msdn forum. here is the link. There is one other step that I was missing. It was setting the parameter in the subreportprocessing event.

https://social.msdn.microsoft.com/Forums/en-US/00aef62a-1ccd-485d-9086-b2af00c7632d/rdlc-passing-parameters-from-main-report-to-subreport?forum=csharpgeneral
0
 

Author Closing Comment

by:nmiller61
ID: 41757608
I was able to get help with the answer from another forum and got my code to work.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now