Avatar of nmiller61
nmiller61
 asked on

RDLC passing parameters from main report to subreport

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.
C#ASP.NET

Avatar of undefined
Last Comment
nmiller61

8/22/2022 - Mon
nmiller61

ASKER
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?
Charles

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
ASKER CERTIFIED SOLUTION
nmiller61

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
nmiller61

ASKER
I was able to get help with the answer from another forum and got my code to work.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck