Passing stored procedure's parameter from Report1 to Report2.

I have two reports: Report1, Report2< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Report1 --- navigation --- jump to a report, which is report2

I can assign a parameter to report2 with no problem.

 

Here is what I did with Rreport2:

I set up a table from a stored procedure ( parameter1 ) in dataset1, and Report2 uses this table as data source.  

 

My question is : how can I pass parameter1 ( which is stored procedure’s parameter ) to Report2 through Report1 ( if I don’t want to add a new web form to do this )

 

Thanks in advance.

 

Long



Answer this question

Passing stored procedure's parameter from Report1 to Report2.

  • C_w

    What is the type of DT   It should be either a System.Data.DataTable or IEnumerable.

  • DavidYA

    Thanks, Rajeev,
    I changed my code and it works just fine, now. Thank you very much for your help.

    Long

  • john blamey

    Can you change the code like this:

    localReport.DataSources.Add(
    new ReportDataSource("DataSetProducts_sp_GetContainerPackingListByContainerNo",
    DT.sp_GetContainerPackingListByContainerNo));


    Note that there are some unfortunate terminology conflicts here, which may the reason for confusion. What RDLC calls a "dataset" is not the same as what ADO.NET calls a "dataset". An RDLC dataset is closer to an ADO.NET datatable than a dataset.

    ReportViewer does not accept ADO.NET datasets. It only accepts ADO.NET datatables. Dataviews are also accepted because Dataviews implement the IEnumerable interface.

  • markmangubat

    Thanks, Rajeev,
    I already tried that, the problem is : how to make the the parametered procedure works.
    here is my drillthrough event:

    protected void ReportViewer1_Drillthrough(object sender, DrillthroughEventArgs e)

    {

    LocalReport localReport = (LocalReport)e.Report;

    ReportParameterInfoCollection Params = e.Report.GetParameters();

    DataSetProducts DT = new DataSetProducts();

    DataSetProductsTableAdapters.sp_GetContainerPackingListByContainerNoTableAdapter myAdp = new DataSetProductsTableAdapters.sp_GetContainerPackingListByContainerNoTableAdapter();

    myAdp.Fill(DT.sp_GetContainerPackingListByContainerNo, Params[0].Values[0]);

    then what should I do to pass the data and show the report
    }


    Thanks in advance.

    Long


  • X-Tatic

    There are some samples on http://www.gotreportviewer.com

    In the drillthrough event handler you can supply data for the drillthrough report as follows:

        void ReportViewer1_Drillthrough(object sender, DrillthroughEventArgs e)
        {
            LocalReport localReport = (LocalReport)e.Report;
            localReport.DataSources.Add(new ReportDataSource("Employees", LoadEmployeesData()));
        }

    It looks like you are correctly examining the parameter values, and filling data into a dataset. Now you have to supply the datatable to the drillthrough report by calling the LocalReport.DataSources.Add() method. That's it. Your drillthrough report should now display.


  • smgtreker

    Hi, Rajeev,

    My drillthrough report ( report2 ) has a dataset named  DataSetProducts_sp_GetContainerPackingListByContainerNo, I tried the following:

    localReport.DataSources.Add(new ReportDataSource("DataSetProducts_sp_GetContainerPackingListByContainerNo", DT));

    the result is :

    • Value does not fall within the expected range.
    •   Is there anything wrong
    • Thanks in advance.
    • Long

  • Matthew!!!

    You can pass a report parameter from the main report to the drillthrough report. Open the Textbox Properties dialog for the textbox that the user will click on to go to the drillthrough report. In the Textbox Properties dialog switch to Navigation tab. Select Jump to report option and select the destination report. Then click the Paramters button. If the destination report has parameters then their values can be supplied as expressions using the Parameters dialog.
  • Qllie

    My drillthrough report ( report2 ) has a dataset named  DataSetProducts_sp_GetContainerPackingListByContainerNo, it call a SQL procedure with parameter "@ContainerNo", I tried the following:

    protected
    void ReportViewer1_Drillthrough(object sender, DrillthroughEventArgs e)

    {

    LocalReport localReport = (LocalReport)e.Report;

    ReportParameterInfoCollection Params = e.Report.GetParameters();

    DataSetProducts DT = new DataSetProducts();

    DataSetProductsTableAdapters.sp_GetContainerPackingListByContainerNoTableAdapter myAdp = new DataSetProductsTableAdapters.sp_GetContainerPackingListByContainerNoTableAdapter();

    myAdp.Fill(DT.sp_GetContainerPackingListByContainerNo, Params[0].Values[0]);

    localReport.DataSources.Add(new ReportDataSource("DataSetProducts_sp_GetContainerPackingListByContainerNo", DT));

    }
    the result is :

    • Value does not fall within the expected range.
    •   Is there anything wrong
    • Thanks in advance.
    • Long


     


  • Passing stored procedure's parameter from Report1 to Report2.