ASP.NET Reporting - An Important Change in the Client-Server Interaction of Report Viewer

DevExpress Data Blog
26 August 2011

This blog post details some changes made in the v2011 vol 1 version of our reporting suite. Specifically I will look at how the ReportViewer in ASP.NET interacts with the server and include some design tips when using our reporting suite in your web applications.

Starting int the newest reporting version, report documents are no longer created on postbacks, but instead created on a callback This allows each page to be generated on demand.

For this reason reports should be assigned to a ReportViewer in the Page_Load event handler. After this, a report document is created every time the Web page is re-loaded.

protected void Page_Load(object sender, EventArgs e) {
    ReportViewer1.Report = new XtraReport1();
} 

The only exception to this rule is when you use a ReportDocumentMap with ReportViewer, in which case a report document is created on a postback (to return its bookmark hierarchy to the client).

In addition, please note that in order to avoid issues regarding the client-server interaction of ReportViewer, we recommend you assign any properties to it either in markup, or in code, but not using both these approaches simultaneously.

Another feature I would like to highlight is of special importance if your Web application is intended to work with large amounts of data.

In this case, you can create your report’s data source exclusively when a report document is being generated in the special XtraReport.DataSourceDemanded event handler. For example:

private void report_DataSourceDemanded(object sender, System.EventArgs e) {
    var dataSet1 = new DataSet1();
    var newRow = dataSet1.DataTable1.NewRow();
    dataSet1.DataTable1.Rows.Add(new object[] { "Field1", "Field2" });
    XtraReport report = (XtraReport) sender;
    report.DataSource = dataSet1;
}
As always, if you have any questions and/or comments, please do let us know!

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.