Solved

RDLC passing parameters from main report to subreport

Posted on 2016-08-03
4
60 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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