locked
Passing parameter to Sub report Issue ( pls help) RRS feed

  • Question

  • User1078912957 posted

    Hi I have main report and one sub report. I used on dataset for main report and one for sub report. I am using Vs2005 .

    Store procedures

    GetMainreport(mid)

    GetSubReport(sId)

    I have setup the report added sub report in main report. I have also setup parameter from main report to sub report.

    It works fine on reporting server.

     

    When I am calling from Asp.net. I am getting error sub report could not be found.

    here is my code

    Report.SubreportProcessing +=

    new SubreportProcessingEventHandler(SubreportProcessingEventHandler);

    void SubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)

        {

     

    e.DataSources.Add(new ReportDataSource("DataSetSubReport", GetDatasoure("dbo.GetSubReport ", e)));

        }

       private SqlDataSource GetDatasoure(String SubReportStoredProcedure,SubreportProcessingEventArgs e)

        {

            SqlDataSource DS = new SqlDataSource(BedsConnectionString.GetString(), SubReportStoredProcedure);

            DS.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;

    How can I pass here Parameter for sub report

           return DS;

       }

    I have main report and I am passing Mainid to subreport GetSubData(sid) to get sub report data(. I used @MainId because I want to be able to send a variable to get the )

    How can I pass in code parameter to subreport.

    Thanks

    Monday, September 20, 2010 10:06 AM

Answers

  • User1471008070 posted

    Hi,

    You should add some paramters for the dataset like these in the code-behind:

    cmd.Parameters.Add("@SiteID", SqlDbType.Int).Value = SelectSite1.Site1;

    cmd.Parameters.Add("@AreaID", SqlDbType.Int).Value = SelectSite1.Area;

    cmd.Parameters.Add("@GateNo", SqlDbType.Int).Value = SelectSite1.Gate;

    cmd.Parameters.Add("@FromDate", SqlDbType.DateTime).Value = SelectTime1.Date; 

    Thanks ,

    Challen Fu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 28, 2010 7:47 AM