Hello everyone!
I am using VS 2005, with SQL 2000. My reports are displaying fine, but i am trying to have a drillthrough report. So basically display one report and once i click on a certain element within the report, it should take me to that specific report, i.e that parameter is passed.
I have rooted through the internet to find a couple of examples which do the same, but these examples use XML as the datasource but I am using a dataset (.xsd) file and cannot get my head around how to interact with this and reload the dataset onto the ReportViewer based on the DrillThrough event the user selects.
The code using the xml file is below, can someone help me to convert this to get it to read data from the xsd file. Both my dataTableAdapters are in the same Dataset. xsd file. I am fairly new at .NET but even i know that this has to be possible.
Cheers,
Munira
private DataTable LoadEmployeesData()
{
DataSet dataSet = new DataSet();
dataSet.ReadXml(@."c:\My Reports\employees.xml");
return dataSet.Tables[0];
}
private DataTable LoadDepartmentsData()
{
//This is the bit that needs to change inorder to read from an xsd file
DataSet dataSet = new DataSet();
dataSet.ReadXml(@."c:\My Reports\departments.xml");
return dataSet.Tables[0];
}
void DemoDrillthroughEventHandler(object sender, DrillthroughEventArgs e)
{
LocalReport localReport = (LocalReport)e.Report;
localReport.DataSources.Add(new ReportDataSource("Employees",
LoadEmployeesData()));
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// On initial page load
ReportViewer1.LocalReport.ReportPath = @."c:\My Reports\Departments.rdlc";
// Supply a DataTable corresponding to each report data source.
ReportViewer1.LocalReport.DataSources.Add(
new ReportDataSource("Departments", LoadDepartmentsData()));
}
// Add the handler for drillthrough.
ReportViewer1.Drillthrough += new DrillthroughEventHandler(DemoDrillthroughEventHandler);
}
Hello all!
I managed to solve my problem after quite a bit of frustration...so I thought that this little check list might be helpful to someone else facing a similar problem.
Ok things to do inorder to make drill down reports work.
1. In the second report (the drillthrough report) add the parameter to the report, in the rdlc page.
2. In the main report, go to the element that you want to click on, the textbox, and make the navigation properties to jump to the second report, also remember to set the parameter in that dialogue box!
3. Add the drillthrougheventhandler in your aspx.cs page, this is the point where you want to change your data source.
4. Make sure you set the reportviewer ondrillthoughevent, in the html definition of the reportviewer, to go to the function writen in 3.
Regards,
Munira
No comments:
Post a Comment