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:
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();
}
}
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;
}
catch (Exception ex)
{
}
}
protected void GenerateReports_Click(object sender, EventArgs e)
{
ShowReport();
}
private void ShowReport()
{
RptVwrClinicWsieApointmentCount.Reset();
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();
ReportParameter[] RptParamsss = new ReportParameter[]
{
new ReportParameter("START_DATETIME",Convert.ToDateTime(txtStartDatetime.Text).ToString()) ,
new ReportParameter("END_DATETIME", Convert.ToDateTime(txtEndDatetime.Text).ToString())
};
RptVwrClinicWsieApointmentCount.LocalReport.SetParameters(RptParamsss);
RptVwrClinicWsieApointmentCount.LocalReport.Refresh();
}
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(); ;
DataTable AppointmentMonthCountSubreport = GetDataSubReport(CLINIC_ID, THERAPIST_ID);
ReportDataSource ds = new ReportDataSource("AppointmentsMonthCount", AppointmentMonthCountSubreport);
e.DataSources.Add(ds);
}
private DataTable GetData(DateTime START_DATETIME, DateTime END_DATETIME)
{
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("@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;
}
}
}