Click here to Skip to main content
15,885,278 members

Problem in DrillDown in Rdlc Reports in Windows Application

Anil Honey 206 asked:

Open original thread
Dear Friends,

Here in DrillDown Report iam facing the Problem.The Problem is Actually iam placing the Reportviewer in TabControl and Dynamically binding the Report view in tabcontrol.In parent Report iam Using the DrillDown Concept and navigate the page to another tab.The data is binding Perfectly in this Two Tabs.But when the Page is Drilldown the Parent Reportview is loosing the path.If i click the back Button its working fine.When i Drill down the Reportviewer from one tab to another tab the Problem is Coming.The parent Reportviewer is loosing his path.
Iam pasting my Code below if i done any thing wrong please rectify it.

private void BindGenderWise()
{
try
{
this.rptEducatorActivities.RefreshReport();
rptEducatorActivities.LocalReport.DataSources.Clear();
strmain1 = "";
strmain2 = "";
dataTableGenderWiseMale.Columns.Clear();
employeeBO.SchoolID = General_Constants.SchoolID;
DataTable dataTable = employeeBL.GetEmployeeCountByGender(employeeBO);


dataTableGenderWiseMale.Columns.Add("Employee", typeof(string));
dataTableGenderWiseMale.Columns.Add("Gender", typeof(string));

DataRow dataRowMale = dataTableGenderWiseMale.NewRow();
if (SEMIS_Language.LanguageName == "en")
dataRowMale["Gender"] = "Male";
else
dataRowMale["Gender"] = "رجل";
dataRowMale["Employee"] = dataTable.Rows[0]["MaleEmployee"].ToString();
dataTableGenderWiseMale.Rows.Add(dataRowMale);

DataRow dataRowFemale = dataTableGenderWiseMale.NewRow();
dataRowFemale["Employee"] = dataTable.Rows[0]["FemaleEmployee"].ToString();
if (SEMIS_Language.LanguageName == "en")
dataRowFemale["Gender"] = "Female";
else
dataRowFemale["Gender"] = "مرأة";
dataTableGenderWiseMale.Rows.Add(dataRowFemale);

if (dataTableGenderWiseMale.Rows.Count > 0)
{
if (SEMIS_Language.LanguageName == "en")
{
this.rptEducatorActivities.RefreshReport();

strmain1 = Application.StartupPath;
strmain2 = strmain1.Replace(@"SEMIS_Start\bin\x64\Debug", "");
this.rptEducatorActivities.LocalReport.ReportPath = strmain2 + @"Zanzibar\XtraReports\Modules\Forms\XtrRptEmpGenderWise_en.rdlc";
ReportDataSource rds = new ReportDataSource("dtGender",dataTableGenderWiseMale);

rptEducatorActivities.LocalReport.DataSources.Add(rds);

this.rptEducatorActivities.RefreshReport();
HeaderDetails();
rptEducatorActivities.Drillthrough += new DrillthroughEventHandler(DemoDrillthroughEventHandler);
}
else
{
this.rptEducatorActivities.RefreshReport();
strmain1 = Application.StartupPath;
strmain2 = strmain1.Replace(@"SEMIS_Start\bin\x64\Debug", "");
this.rptEducatorActivities.LocalReport.ReportPath = strmain2 + @"Zanzibar\XtraReports\Modules\Forms\XtrRptEmpGenderWise_en.rdlc";
ReportDataSource rds = new ReportDataSource("dtGender", dataTableGenderWiseMale);

rptEducatorActivities.LocalReport.DataSources.Add(rds);

this.rptEducatorActivities.RefreshReport();
HeaderDetails();
rptEducatorActivities.Drillthrough += new DrillthroughEventHandler(DemoDrillthroughEventHandler);
}
}


else
{

}
}
catch (Exception ee)
{
loadErrorsLog.ErrorMethod(ee.Message, this.Name, "BindGenderWise");
}
}



void DemoDrillthroughEventHandler(object sender, DrillthroughEventArgs e)
{
int index = 0;
//Variable to store the parameter value passed from the MainReport.
string val = "0";
string M = "";
//Get the instance of the Target report, in our case the JumpReport.rdlc.
LocalReport report = (LocalReport)e.Report;
//Get all the parameters passed from the main report to the target report.
//OriginalParametersToDrillthrough actually returns a Generic list of
//type ReportParameter.
IList<reportparameter> list = report.OriginalParametersToDrillthrough;
//Parse through each parameters to fetch the values passed along with them.
foreach (ReportParameter param in list)
{
//Since i know the parameter is only one and its not a multivalue
//I can directly fetch the first value from the Values array.
val = param.Values[0].ToString();
}

TabPage xtraTabPage = new TabPage();


ReportViewer printControl = new ReportViewer();

if (index == 0)
{
foreach (System.Windows.Forms.TabPage tp in tabControlEx1.TabPages)
{


if (tp.Text == "Gender Name -" + val.Trim())
{
tabControlEx1.SelectedTab = tp;
goto endloop;
}
}

if (SEMIS_Language.LanguageName == "en")
xtraTabPage.Text = "Gender Name -" + val.Trim();
else
xtraTabPage.Text = " إسم الجنس -" + val.Trim();
if (val == "Male" || val == "Female" || val == "رجل" || val == "مرأة")
{
M = val.Remove(1);
EmployeeBL employeeBL = new EmployeeBL();
EmployeeBO employeeBO = new EmployeeBO();
employeeBO.Gender = Convert.ToChar(M);
employeeBO.SchoolID = General_Constants.SchoolID;
DataTable dataTableTotalGenders = new DataTable();
dataTableTotalGenders = employeeBL.GetEmployeeNamesByGender(employeeBO);

if (dataTableTotalGenders.Rows.Count > 0)
{
if (SEMIS_Language.LanguageName == "en")
{
printControl.Dock = DockStyle.Fill;
printControl.RefreshReport();

string str = Application.StartupPath;
string str2 = str.Replace(@"SEMIS_Start\bin\x64\Debug", "");
printControl.LocalReport.ReportPath = str2 + @"Zanzibar\XtraReports\Modules\Forms\XtrRptEmpNamesGenderWise_en.rdlc";
ReportDataSource rds1 = new ReportDataSource("dtempnames", dataTableTotalGenders);

printControl.LocalReport.DataSources.Add(rds1);
schoolBO.AcademicYearID = General_Constants.AcademicYearID;
DataTable dtSchInfo = new DataTable();

dtSchInfo = schoolBL.SelectByAcademicYear(schoolBO);

if (dtSchInfo.Rows[0]["SchoolLogo"].ToString() != "")
{
byte[] schImage = (byte[])dtSchInfo.Rows[0]["SchoolLogo"];
MemoryStream ms = new MemoryStream();
ms.Write(schImage, 0, schImage.Length);
Image image = Image.FromStream(ms);
// Bitmap bmp = new Bitmap(image, Convert.ToInt32(lblSchoolLogo.WidthF), Convert.ToInt32(lblSchoolLogo.HeightF));
ReportParameter[] paramtr = new ReportParameter[3];
string dname = dtSchInfo.Rows[0]["DistrictName"].ToString();
string proname = dtSchInfo.Rows[0]["ProvinceName"].ToString();
string cname = dtSchInfo.Rows[0]["Country"].ToString();
string Name = dname + ',' + proname + ',' + cname;
// paramtr[0] = new ReportParameter("Image", image.ToString());
paramtr[0] = new ReportParameter("AcademicYear", dtSchInfo.Rows[0]["Year"].ToString());
paramtr[1] = new ReportParameter("SchoolName", dtSchInfo.Rows[0]["SchoolName"].ToString());
paramtr[2] = new ReportParameter("CountryName", Name);
//paramtr[3] = new ReportParameter("Info", "Gender Wise Employee Activities");
printControl.LocalReport.SetParameters(paramtr);
printControl.RefreshReport();
}

xtraTabPage.Controls.Add(printControl);
printControl.RefreshReport();
this.tabControlEx1.SuspendLayout();
tabControlEx1.TabPages.Add(xtraTabPage);
tabControlEx1.SelectedTab = xtraTabPage;

}
else
{
printControl.Dock = DockStyle.Fill;
printControl.RefreshReport();

string str = Application.StartupPath;
string str2 = str.Replace(@"SEMIS_Start\bin\x64\Debug", "");
printControl.LocalReport.ReportPath = str2 + @"Zanzibar\XtraReports\Modules\Forms\XtrRptEmpNamesGenderWise_ar.rdlc";
ReportDataSource rds1 = new ReportDataSource("dtempnames", dataTableTotalGenders);

printControl.LocalReport.DataSources.Add(rds1);
schoolBO.AcademicYearID = General_Constants.AcademicYearID;
DataTable dtSchInfo = new DataTable();

dtSchInfo = schoolBL.SelectByAcademicYear(schoolBO);

if (dtSchInfo.Rows[0]["SchoolLogo"].ToString() != "")
{
byte[] schImage = (byte[])dtSchInfo.Rows[0]["SchoolLogo"];
MemoryStream ms = new MemoryStream();
ms.Write(schImage, 0, schImage.Length);
Image image = Image.FromStream(ms);
// Bitmap bmp = new Bitmap(image, Convert.ToInt32(lblSchoolLogo.WidthF), Convert.ToInt32(lblSchoolLogo.HeightF));
ReportParameter[] paramtr = new ReportParameter[3];
string dname = dtSchInfo.Rows[0]["DistrictName"].ToString();
string proname = dtSchInfo.Rows[0]["ProvinceName"].ToString();
string cname = dtSchInfo.Rows[0]["Country"].ToString();
string Name = dname + ',' + proname + ',' + cname;
// paramtr[0] = new ReportParameter("Image", image.ToString());
paramtr[0] = new ReportParameter("AcademicYear", dtSchInfo.Rows[0]["Year"].ToString());
paramtr[1] = new ReportParameter("SchoolName", dtSchInfo.Rows[0]["SchoolName"].ToString());
paramtr[2] = new ReportParameter("CountryName", Name);
//paramtr[3] = new ReportParameter("Info", "Gender Wise Employee Activities");
printControl.LocalReport.SetParameters(paramtr);
printControl.RefreshReport();
}

xtraTabPage.Controls.Add(printControl);
printControl.RefreshReport();
this.tabControlEx1.SuspendLayout();
tabControlEx1.TabPages.Add(xtraTabPage);
tabControlEx1.SelectedTab = xtraTabPage;
//BindGenderWise();
}

}
}


}
endloop: ;
}


But when the Drilldown is happening the Parent Report loosing his path.
Tags: C# (C# 4.0)

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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