|
Article relates to
|
Telerik Reporting 2.x+
|
|
Created by
|
Steve, Telerik
|
|
Last modified
|
28 April, 2009
|
|
Last modified by
|
Steve, Telerik
|
HOW-TO
Use Out-Proc session with Telerik Reporting
SOLUTION
The ReportViewer control uses the session state to preserve the report instance assigned to its Report property during page postbacks and for some other design reasons as well. Sometimes because of different requirements the web application has to be configured to use an out-proc session state such as SQLServer or StateServer. When this is the case, the report instance has to be serialized and deserialized in contrast to the InProc session state mode where the report just stays in memory and is available at any time as it is. However, during the deserialization of the session object, the report is instantiated again through its default constructor which leads to the following limitations:
- The report should have a default constructor (constructor without parameters i.e. parameterless constructor).
- All modifications made to the report instance, after the default constructor has been called are ignored.
Additionally the values of the report’s DataSource and DataMemeber properties and the current values of the report parameters are also preserved in Session. The latter is especially important and can be used to pass values from the page with the ReportViewer control to the report definition. This is achieved by using the parameters in expressions where they are supported (e.g. Value properties; Filter, Sorting and Grouping expressions; etc.).
As the value of the DataSource property is kept in the Session, it is also recommended to use the NeedDataSource event to populate the report with data that when in an out-proc session mode. Otherwise the Session will either become very large, especially when using large datasets or the data for the report will not be serialized at all if it cannot be binary serialized/deserialized (e.g. business objects, anonymous types, data adapters, etc.). Again you can use the parameters’ values to pass specific information needed to retrieve the relevant data in the NeedDataSource event.
Example 1: Modifying the Value of a TextBox item using an expression and a
report parameter.
The goal is to change the value of a TextBox item in the report, according to the selected value in a drop down list:
- The SelectedIndexChanged event handler of the DropDownList:
- The expression for the Value property of the TextBox item:

- Setting the report parameter (please use the scroll bellow to see the whole image):

Example 2: Using report parameters to retrieve specific data.
The goal is to retrieve a name depending on the selected year from a drop
down list:

- The SelectedIndexChanged event handler implementation of the DropDownList:
C#
VB.NET
- Expressions for the TextBox items:

- Setting the report parameter (please use the scroll bellow to see the whole image):

- The NeedDataSource event of the report:
C#
VB.NET
- A sample method with a parameter to retrieve the relevant data. You should implemented your way for getting the data here:
C#
VB.NET
Please
Sign In
to rate this article.