I pass in 3 querystring parameters to my web form. The Object Data Sources pick up these parameters
and select the appropriate records.
I want to display one of the querystring parameters in my Page Header, specifically the one for Fiscal Year.
I could return the Fiscal Year in a column from the data source, but the Fiscal Year would not populate if
no records were returned...Therefore, I must get the querystring parameter that was originally passed in...
How do I populate the report control textbox with the value of querystring parameter?
Thanks!
Jim
JIM_LANGDON wrote:
I pass in 3 querystring parameters to my web form. The Object Data Sources pick up these parameters
and select the appropriate records.
I want to display one of the querystring parameters in my Page Header, specifically the one for Fiscal Year.
I could return the Fiscal Year in a column from the data source, but the Fiscal Year would not populate if
no records were returned...Therefore, I must get the querystring parameter that was originally passed in...
How do I populate the report control textbox with the value of querystring parameter?
Thanks!
Jim
Are you using a report generator?
If not, then isn't this is as simple as setting the expression of the textbox to:
=Fields!FiscalYear.Value
|||I don't know what you mean by "Report Generator"..isn't it SSRS?
I pass in the parameter via the call to the webform that contains the
reportviewer control -- webform.aspx?fy=2007.
The reportviewer control that is bound to the report.rdlc.
The RDLC has several datasources which show up as objectdatasource controls
on the web form. The objectdatasource controls are configured to use the appropriate
datasource method and the parameters are defined to use the querystring and "fy" as
the parameter name.
Doesn't the Fields! collection just have the datasource columns? I tried what you suggested
Fields!fy.Value, since the name in querystring is "fy"...no success.
|||
JIM_LANGDON wrote:
I tried what you suggested
Fields!fy.Value, since the name in querystring is "fy"...no success.
This is probably because you need to specify the dataset on the textbox. Right click the textbox and select properties. In the "containing group or dataset" textbox, you need to either select or enter the dataset that contains 'fy'.
Basically, you can treat a textbox similarly to a table/matrix. It can have a dataset associated with it and you can populate the textbox with any value from the parameters or fields list.
|||But the querystring does not belong to a "dataset"....so I can't reference it with Fields!fieldname. Hmmm.
|||Isn't fiscal year one of your fields in a dataset? Aren't you trying to get fiscal year in a textbox?
Why do you want to touch a querystring?
|||I could return the Fiscal Year in a column from the data source, but the Fiscal Year would not populate if
no records were returned...Therefore, I must get the querystring parameter that was originally passed in...
The goal is to display a specific querystring parameter in the page header of the report.
|||
JIM_LANGDON wrote:
I could return the Fiscal Year in a column from the data source, but the Fiscal Year would not populate if
no records were returned
Yes, and you could conditionally specify what the Fiscal Year should default to if no records are returned.
If you'd like to pursue the querystring path to resolve this, feel free. I'm just somewhat confused with your reasoning.
|||The Fiscal Year that is passed to the web form is 2006. If no Fiscal Year is passed, it will default to 2007. The records selected are based on the year that is passed in.
If I pass in the year 2006, I want the page header to display "Fiscal Year: 2006" and the body to display "No records found."
It seems clear to me that the querystring is the only place to logically capture the Fiscal Year. Is there another method you had in mind to meet the goal or another way to do things to accomplish the same thing?
|||
JIM_LANGDON wrote:
It seems clear to me that the querystring is the only place to logically capture the Fiscal Year. Is there another method you had in mind to meet the goal or another way to do things to accomplish the same thing?
Maybe I just don't know what you mean by "querystring".
I think everything that you have mentioned so far can be accomplished by using a dataset (as either text or stored procedure).
|||Sounds like what you have to do is one of the following:
add a new parameter to the report (with no valid values) and set the value of this parameter from the querystring. In your report textbox use Parameters!<your param name>.value to display the value
OR
create a new dataset in your report and load the querystring parameters into it in code, pass this additional dataset to the report
|||The report page is initiated by a link <a>, html anchor tag.
<a href="report_web_form.aspx?fy=2006">Run This Report</a>
The href property assignment is what I mean by "querystring".
The dataset that is generated uses the 2006 value to determine what
records to select. If no records are returned, you cannot use the dataset to
get the value 2006. I don't see how this can be accomplished using a dataset.
|||Thanks Adam..
From your first solution how do I "set the value of this parameter from the querystring". Where is that done. Are we talking about an assignment in the page load event of the report web form?
From your second solution how do I "load the querystring parameters into it in code"?
Sorry, I just need a bit more explanation.
|||OK, here we go. The solution. Thanks to the exhausting yet always productive discussion today.
1. Define a report parameter in the report.rdlc:
Name: FISCAL_YEAR
Data Type: String
"Hidden" checkbox checked.
Default Values: "null" checkbox checked.
2. Place a text box in the page header of the report.rdlc with the value "=parameters!FISCAL_YEAR.Value".
3. Place the following code in the report web form:
Imports Microsoft.Reporting.WebForms
Partical Class reportWebForm
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim _fiscalYearParameter As New ReportParameter("FISCAL_YEAR", "2007")
_fiscalYearParameter.Values(0) = Request.QueryString("fy")
ReportViewer.LocalReport.SetParameters(New ReportParameter() {_fiscalYearParameter})
End Sub
No comments:
Post a Comment