Click here to Skip to main content
15,887,872 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
While creating Sub Report through RDLC in C# asp.net web application I found an error related to the

RptVwrClinicWsieApointmentCount.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(Subreport_AppointmentMonthCount);


I tried the following below mentione code... Please suggest me what else I need to remove the following error :-

What I have tried:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Globalization;
using System.IO;

using System.Configuration;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;

namespace Theraplan
{
    public partial class ClinicWiseAppointmentCount : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                FillClinicList();
                //FillTherapistList(ddlClinicNames.SelectedValue.ToString());


            }
        }
        private void FillClinicList()
        {
            try
            {

                TCA_Appointment_DLL objDLL = new TCA_Appointment_DLL();
                DataTable dtClinic = null;

                dtClinic = objDLL.getClinicList();

                ddlClinicNames.DataSource = dtClinic;
                ddlClinicNames.DataValueField = "Clinic Id";
                ddlClinicNames.DataTextField = "Clinic Name";
                ddlClinicNames.DataBind();


                ddlClinicNames.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", ""));

                ddlClinicNames.ClearSelection();
                ddlClinicNames.SelectedIndex = 0;

                // ddlClinicNames_SelectedIndexChanged(null, null);
            }
            catch (Exception ex)
            {

            }

        }

        protected void GenerateReports_Click(object sender, EventArgs e)
        {
            ShowReport();
           
        }
        private void ShowReport()
        {
            //Reset

            RptVwrClinicWsieApointmentCount.Reset();
            //ddlClinicNames.Text,
            DataTable dt = GetData(Convert.ToDateTime(txtStartDatetime.Text), Convert.ToDateTime(txtEndDatetime.Text));


            RptVwrClinicWsieApointmentCount.Reset();
            RptVwrClinicWsieApointmentCount.LocalReport.ReportPath = "ClinicWiseAppointmentCount.rdlc";
            ReportDataSource rds = new ReportDataSource("ClinicWiseAppintmentCountDataSet", dt);

            RptVwrClinicWsieApointmentCount.LocalReport.DataSources.Add(rds);
            

            RptVwrClinicWsieApointmentCount.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(Subreport_AppointmentMonthCount);
            RptVwrClinicWsieApointmentCount.LocalReport.Refresh();
            //DataSource
            //Added For Sub Reports
            
            
            //Added For Sub Reports 
            

            
            //Path

            //Parameter
            ReportParameter[] RptParamsss = new ReportParameter[]
            {
          //  new ReportParameter("CLINIC_ID",ddlClinicNames.Text),
            new ReportParameter("START_DATETIME",Convert.ToDateTime(txtStartDatetime.Text).ToString()) ,
            new ReportParameter("END_DATETIME", Convert.ToDateTime(txtEndDatetime.Text).ToString()) 
            };
            //Refresh
            RptVwrClinicWsieApointmentCount.LocalReport.SetParameters(RptParamsss);
            RptVwrClinicWsieApointmentCount.LocalReport.Refresh();
        }

        //Added for Sub Reports
        //void localReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
        //{
        //    e.DataSources.Add(new ReportDataSource("AppointmentsMonthCount", SqlDs_RefsReportsSub));
        //}
        void Subreport_AppointmentMonthCount(object sender, SubreportProcessingEventArgs e)
        {
            string CLINIC_ID = e.Parameters["CLINIC_ID"].Values[0].ToString();
            string THERAPIST_ID = e.Parameters["THERAPIST_ID"].Values[1].ToString(); ;
            //TextBox1.Text, TextBox2.Text
            DataTable AppointmentMonthCountSubreport = GetDataSubReport(CLINIC_ID, THERAPIST_ID);
            ReportDataSource ds = new ReportDataSource("AppointmentsMonthCount", AppointmentMonthCountSubreport);
            //ds.DataSourceId = "ObjectDataSource1";





            //ds.Name = "AppointmentsMonthCount";
            e.DataSources.Add(ds);
            // e.DataSources.Add(new ReportDataSource("AppointmentsMonthCount",(object) AppointmentsMonthCountDataSet.SP_TCA_GET_APPOINTMENT_COUNT_BY_MONTHDataTable));
        }

        //Added For Sub Reports
        private DataTable GetData(DateTime START_DATETIME, DateTime END_DATETIME)
        {//string CLINIC_ID, 
            DataTable dt = new DataTable();
            string conString = ConfigurationManager.ConnectionStrings["TCAConnectionStringNew"].ConnectionString;
            using (SqlConnection con = new SqlConnection(conString))
            {
                con.Open();
                SqlCommand cmd1 = new SqlCommand("SP_TCA_GET_APPOINTMENT_CLINICWISE", con);
                cmd1.CommandType = CommandType.StoredProcedure;
              //  cmd1.Parameters.Add("@CLINIC_ID", SqlDbType.NVarChar).Value = CLINIC_ID;
                cmd1.Parameters.Add("@START_DATETIME", SqlDbType.DateTime).Value = START_DATETIME;
                cmd1.Parameters.Add("@END_DATETIME", SqlDbType.DateTime).Value = END_DATETIME;
                SqlDataAdapter adp = new SqlDataAdapter(cmd1);
                adp.Fill(dt);
                con.Close();
            }
            return dt;
           
        }
        private DataTable GetDataSubReport(string CLINIC_ID, string THERAPIST_ID)
        {
            DataTable dt = new DataTable();
            string conString = ConfigurationManager.ConnectionStrings["TCAConnectionStringNew"].ConnectionString;
            using (SqlConnection con = new SqlConnection(conString))
            {
                con.Open();
                SqlCommand cmd1 = new SqlCommand("SP_TCA_GET_APPOINTMENT_COUNT_BY_MONTH", con);
                cmd1.CommandType = CommandType.StoredProcedure;
                cmd1.Parameters.Add("@CLINIC_ID", SqlDbType.NVarChar).Value = CLINIC_ID;
                cmd1.Parameters.Add("@THERAPIST_ID", SqlDbType.NVarChar).Value = THERAPIST_ID;
                SqlDataAdapter adp = new SqlDataAdapter(cmd1);
                adp.Fill(dt);
                con.Close();
            }
            return dt;
        }

 
       
    }
}
Posted
Updated 18-Jun-16 21:39pm
v2
Comments
OriginalGriff 19-Jun-16 3:40am    
What error?
Any message?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900