I am trying to create a report with parameters which are prompted by the user and are initially populated with default values. However, whenever I edit the parameters in Report Viewer and click 'View Report', the parameter values revert to their default value. The user-specified parameters never "stick".
Please help!
The xml looks like this:
<ReportParameters>
<ReportParameter Name="ConnectString">
<DataType>String</DataType>
<Prompt>ConnectString</Prompt>
<Hidden>true</Hidden>
</ReportParameter>
<ReportParameter Name="FromDate">
<DataType>DateTime</DataType>
<DefaultValue>
<Values>
<Value>2006-1-1</Value>
</Values>
</DefaultValue>
<AllowBlank>true</AllowBlank>
<Prompt>From:</Prompt>
</ReportParameter>
<ReportParameter Name="ToDate">
<DataType>DateTime</DataType>
<DefaultValue>
<Values>
<Value>2006-12-31</Value>
</Values>
</DefaultValue>
<AllowBlank>true</AllowBlank>
<Prompt>To:</Prompt>
</ReportParameter>
</ReportParameters>
One more observation: It works within Report Manager. The problem is when the report is hosted in my application. It seems there might be something in my code that is causing the user-specified parameters to be ignored.
I tried eliminating SetParameters call for the one hidden parameter, and I made sure I was setting ShowParameterPrompts attribute once (in case changing value would reset parameters). The problem still exists.
|||One possible cause is that you are setting the report path or report server url after the LoadViewState event on the postback. If you do this, the report viewer control will see this as a change in the report definition and reload the report from the server, ignoring any input from the postback because it applies to the "old report". Try setting the report path/server url during OnInit, or only when Page.IsPostBack is false.|||Thank you Brian! That worked!
I verified that either setting ServerReport properties in OnInit(), or after checking Page.IsPostBack is false in Page_Load(), will fix this problem. I also had to call SetParameters within these same constraints.
On to new problems...
No comments:
Post a Comment