Solved

RDLC passing parameters from main report to subreport

Posted on 2016-08-03
4
101 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Coding for the first time 9 67
Record locking on classic ASP 3 38
orderby list (from Json) 1 29
c#, datatable, aspx 4 19
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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!

749 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