locked
Sub Report Parameter Issue please help RRS feed

  • Question

  • User1623409651 posted

    Hi all ,

    I have to pass the sub report paramter programmtically to rdlc report Here is my code 

            void report_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
            {
                ReportsBusinessLogic objReportBusinessLogic = new ReportsBusinessLogic();
               
    
                DataSet SubReport = new DataSet();
                objReportBusinessLogic.EmployeeId = Convert.ToInt32(e.Parameters["EmployeeId"].Values[0].ToString());
                SubReport = objReportBusinessLogic.GetEmployeeAllwoancesDetailsforPayslip("DatasetName");
                ReportDataSource dsReportDataSource2 = new ReportDataSource();
                dsReportDataSource2.Name = SubReport.Tables[0].TableName;
                dsReportDataSource2.Value = SubReport.Tables[0];
                // Here i need to pass the parameter to subreport
                
                e.DataSources.Add(dsReportDataSource2);
    
    
    
            }
    

    Please suggest 

    Thursday, October 18, 2012 3:21 AM

Answers

  • User1630798415 posted

    why are you going from code behind?

    if you want, you can configure parameters by configuration interface as mentioned below

    http://forums.asp.net/p/1432888/4083549.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 18, 2012 11:54 PM
  • User-8475372 posted

    Dear User, 

    For sending a parameter to a report, you need to pass like this : 

                   Microsoft.Reporting.WebForms.ReportParameter[] RptParameters;

                  
                    RptParameters = new Microsoft.Reporting.WebForms.ReportParameter[1];
                    RptParameters[0] = new Microsoft.Reporting.WebForms.ReportParameter("                                               <ParameterName>", "<ParameterValue>");               
                    this.reportViewer.ServerReport.SetParameters(RptParameters);     
                    reportViewer.ServerReport.Refresh();


    You can pass any number of parameters to the report. Just make sure that the <ParameterName> matches with the parameter name in the report. 

    Now, for getting the subreport, right click on the cell content ( on clicking which you want to get your subreport ), select Action and there you can mention the url of the subreport name and even the parameters for that subreport. 

    Try checking this article as well : http://msdn.microsoft.com/en-us/library/ms160348(v=sql.100).aspx

    Mark As Answer if it Helps !! 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 19, 2012 2:02 AM

All replies

  • User1630798415 posted
    Public Sub SubreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs) 
    
        ObjectDataSource2.SelectParameters("Param1") = New Parameter("Param1", DbType.Int32, e.Parameters.Item(0).Values(0))          
    
         ObjectDataSource2.SelectParameters("Param2") = New Parameter("Param2", DbType.String, e.Parameters.Item(1).Values(0)) 
    
        e.DataSources.Add(New ReportDataSource("SubReportDataSourceName", ObjectDataSource2)) 
    End Sub 
    
    


    Thursday, October 18, 2012 3:44 AM
  • User1623409651 posted

    Public Sub SubreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
    
        ObjectDataSource2.SelectParameters("Param1") = New Parameter("Param1", DbType.Int32, e.Parameters.Item(0).Values(0))
    
         ObjectDataSource2.SelectParameters("Param2") = New Parameter("Param2", DbType.String, e.Parameters.Item(1).Values(0))
    
        e.DataSources.Add(New ReportDataSource("SubReportDataSourceName", ObjectDataSource2))
    End Sub
    
    

    
    

    I have already treid the above code but did not succeeed please look into the issue and reply please . There is no SelectParameters option with object data source although iam using ReportDataSource instead of object datasource

    Regards,

    Thursday, October 18, 2012 3:49 AM
  • User1623409651 posted

    Any Idea i hve to populate the subreprot based upon the employeeId from Parent report please guide me 

    Regards,

    Thursday, October 18, 2012 5:23 AM
  • User1630798415 posted

    why are you going from code behind?

    if you want, you can configure parameters by configuration interface as mentioned below

    http://forums.asp.net/p/1432888/4083549.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 18, 2012 11:54 PM
  • User-8475372 posted

    Dear User, 

    For sending a parameter to a report, you need to pass like this : 

                   Microsoft.Reporting.WebForms.ReportParameter[] RptParameters;

                  
                    RptParameters = new Microsoft.Reporting.WebForms.ReportParameter[1];
                    RptParameters[0] = new Microsoft.Reporting.WebForms.ReportParameter("                                               <ParameterName>", "<ParameterValue>");               
                    this.reportViewer.ServerReport.SetParameters(RptParameters);     
                    reportViewer.ServerReport.Refresh();


    You can pass any number of parameters to the report. Just make sure that the <ParameterName> matches with the parameter name in the report. 

    Now, for getting the subreport, right click on the cell content ( on clicking which you want to get your subreport ), select Action and there you can mention the url of the subreport name and even the parameters for that subreport. 

    Try checking this article as well : http://msdn.microsoft.com/en-us/library/ms160348(v=sql.100).aspx

    Mark As Answer if it Helps !! 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 19, 2012 2:02 AM