locked
rdlc sub report event is not firing RRS feed

  • Question

  • User-2072162984 posted

    Hi

    I created rdlc report  with sub report

     

     sub report event  is not working.The cursor is not coming to event during debugging.If i run with out sub report,main report is working.

    I have given the code below

    ReportViewer1.Visible = true;
                            DataSet DataSet1 = new DataSet();
    
                            con = new SqlConnection(GetConnectionString());
                            con.Open();
                                                
    
                        
                            ReportViewer1.LocalReport.SubreportProcessing +=new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
    
    
                            string strQryString = "SELECT        CUSTOMERDETAILS.CustomerName,CUSTOMERDETAILS.CompanyName, Followup.CustomerNo, Followup.MeetingDate, Followup.MeetingType, Followup.Subject, Followup.MinutesofDiscussion, "
                           
                            + "    frOM            CUSTOMERDETAILS INNER JOIN"
                            + "   Followup ON CUSTOMERDETAILS.CustomerNo = Followup.CustomerNo INNER JOIN"
                            + "                         USERDETAILS ON Followup.MailTo = USERDETAILS.UNo where Followup.MailTo=" + Session["UNo"] + "";
                            SqlCommand cmd1 = new SqlCommand(strQryString, con);
    
                            SqlDataAdapter da = new SqlDataAdapter(cmd1);
                            da.Fill(DataSet1);
                            ReportDataSource datasource = new ReportDataSource("DataSet1", DataSet1.Tables[0]);
                            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report.rdlc");
                            ReportViewer1.LocalReport.DataSources.Clear();
                            ReportViewer1.LocalReport.DataSources.Add(datasource);

    void LocalReport_SubreportProcessing(object sender, Microsoft.Reporting.WebForms.SubreportProcessingEventArgs e)//cursor is not coming to this line
    {

    Fupid = Convert.ToInt32(e.Parameters[0].Values[0]);//passing the parameter

    DataTable dt = getAttendies();//call function in sub report
    e.DataSources.Add(new ReportDataSource("DataSet2",dt));
    }

    public DataTable getAttendies()
    {
    SqlConnection con = new SqlConnection(GetConnectionString());
    con.Open();
    string SqlQry = "select * from FOLLOWUPREQUESTCONTACTS where Fupid=" + Fupid + "";
    DataTable dt = new DataTable();

    SqlCommand sqlcmd = new SqlCommand(SqlQry, con);

    SqlDataAdapter da = new SqlDataAdapter(sqlcmd);
    da.Fill(dt);
    return (dt);

    }

    Please help me.

    Thanks

    chandran

    Thursday, October 10, 2013 1:20 AM

Answers

  • User-734925760 posted

    Hi,

    Please vheck the subreport parameters. If a parameter condition fails, the subreport is not loaded. Also check Visual Studio trace output, it shows which parameter causes the error.

    void LocalReport_SubreportProcessing(object sender, Microsoft.Reporting.WebForms.SubreportProcessingEventArgs e)//cursor is not coming to this line
    {

    Fupid = Convert.ToInt32(e.Parameters[0].Values[0]);//passing the parameter

    In the LocalReport_SubreportProcessing function, we set the parameter, but as we call the getAttendies, didn't pass the parameter to this function, the code as below:

    public DataTable getAttendies()

    Please refer to update this function as below:

    public DataTable getAttendies(String Fupid  )


    Also we can set the parameter allow null.

    Hope it's useful for you.

    Best Regards,

    Michelle Ge

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 11, 2013 4:57 AM