RDLC report how to create multiple?
Yes it's possible to have one report for all customers. Basically you define your report template CustomerReport.rdlc to get data from some dataset (a stored procedure or some method in your datalayer).
for ex. your method should look something like this:
public DataTable GetCustomerDetails(int customerID)
{
//call stored procedure
}
Then on the page where is ReportViewer you do something like this:
DataTable data = GetCustomerDetails(1);
this.ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
this.ReportViewer1.LocalReport.ReportPath = "CustomerReport.rdlc";
this.ReportViewer1.LocalReport.DataSources.Clear();
this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("[Datasource name defined in CustomerReport.rdlc]", data));
this.ReportViewer1.LocalReport.Refresh();
A single reportviewer control will show a single .rdlc document, along with any subreports included in the "parent" .rdlc "at a time". If you working in web forms it is also a best practice to not attempt to 'reload' a second report into a report viewer. It is better to empty the div containing the reportviewer and creating a new instance of the reportviewer control and insert that into the container (div/span/etc.)
After that it is just a matter of making sure you have the customer specific data assigned as the datasource.
Solution seems to be code generated rdlc!!
精彩评论