开发者

RDLC report how to create multiple?

Suppose that you have a report CustomerReport.rdlc which is for one customer....

Is it possible to have multiple customers reports in the same reportviewer?

If 开发者_如何学Cnot what is another solution ?


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!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜