|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 1:00 PM
Points: 62,
Visits: 109
|
|
Hi,
I am trying to create a report in C#, WPF using Visual Studio 2010 and the ReportViewer to display an RDLC (Client Side Report) but am having difficulty finding any examples/tutorials on this.
The report is to show some customer details along with two subreports, one showing the customer's email addresses and one showing the customer's phone numbers.
I have created the Email Address subreport which accepts a parameter called Cus_PK (the customer Primary Key) and has a dataset based on the email addresses table.
I have created the customer report and dropped tablix which is driven by the customer dataset and a subreport on it setting the properties of the subreport to my email address subreport and passing the parameter of Cus_PK - the PKs are guid/uniqueidentifiers so I set the value of the parameter like this: =Fields!cus_PK.Value.ToString()
From what I have found online I need to handle the subreport processing in code but have not found an example close to what I am doing:
// Add a handler for the SubreportProcessing event _reportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
private void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e) { Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource(); CustomerListingEmailDataSet dataset = new CustomerListingEmailDataSet(); dataset.BeginInit(); dataset.EnforceConstraints = false; reportDataSource1.Name = "DataSet1";
reportDataSource1.Value = dataset.EmailAddressesSelectByCustomerFK; this._reportViewer.LocalReport.DataSources.Add(reportDataSource1);
this._reportViewer.LocalReport.ReportEmbeddedResource = "SamaanSystems.IBC.WPF.Reports.CustomerListingEmailSubReport.rdlc"; //this._reportViewer.LocalReport.ReportEmbeddedResource = "SamaanSystems.IBC.WPF.Reports.CustomerListing.rdlc"; dataset.EndInit();
CustomerListingEmailDataSetTableAdapters.EmailAddressesSelectByCustomerFKTableAdapter emailTableAdapter = new CustomerListingEmailDataSetTableAdapters.EmailAddressesSelectByCustomerFKTableAdapter();
emailTableAdapter.ClearBeforeFill = true; Guid cusPK = new Guid(e.Parameters[0].Values[0]); emailTableAdapter.Fill(dataset.EmailAddressesSelectByCustomerFK, cusPK);
e.DataSources.Add(new ReportDataSource(e.DataSourceNames[0], "CustomerListingEmailDataSet")); }
Is this the way to do it? If so, I am getting a message on the report preview: some parameters or credentials have not been specified
Can anyone help me over this last hurdle, please?
|
|
|
|