I’m showing a remote report in a ReportViewer control. The report loads with a few default parameters. So far everything is ok.
But when i change a few input values and hit View Report then the report simply shows the data with the default values. The parameters that i changed in the input fields are also reset.
All the code i have is this:
apsx
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" Height="642px" ProcessingMode="Remote" Width="100%">
<ServerReport ReportPath="http://server.com/Product/Dashboards/test.rdl"
ReportServerUrl="http://server.com/ReportServer" />
</rsweb:ReportViewer>
The CodeBehind is basically empty. All it has now is an empty Page_Load.
That is all my code.
But it feels like a ViewState issue? But I am not sure where to look.
Anyone any idea why the parameters are resrt when I press on the View Report button?
I solved this by setting the parameters myself in the Code Behind. So when the report is submitted, i then get all the entered data, put that in a
ReportParameterscollection.But unfortunately this wasn’t as easy and straight forward as one would think. At first you might think this is stored in:
YourReport.ServerReport.GetParameters(). But that is not the case!To get the submitted values from your report you can use the following code:
Get report submitted parameters
Source: http://forums.asp.net/t/1057747.aspx/1 (Also Visual Basic examples)
You invoke those methods by just using the following line of code. Preferably in a
if(IsPostBack)scope within yourPage_Loadfor example.It is then possible to overwrite the submitted values if you also have custom textfields. You can easily do that like so:
You obviously have to know what param is stored at index
4. But you could also make an easy lookup function that searches for thereportParameterwith a specific name. So in my caseyear.Simple parameter lookup
You use that like so:
This way you don’t have to worry about at what
indexa certain parameter is placed.