I have created a local report on a datasource that has a field named "RelativePath". When my WinForms app renders the report, it exports files to the location specified in the RelativePath field. In the report builder, I set Navigation|Hyperlink action|Jump to URL to "=Fields!RelativePath.Value" and set the report's EnableHyperlink property to true. Whenever my app renders the report, however, the hyperlink is not active. If I hardcode the Jump to URL to an absolute path, however, it works just fine. Does the ReportViewer not render a hyperlink with a relative path?
问题:
回答1:
I have been struggling with the same problem after which i came to the conclusion that the reportviewer does not support hyperlinks with the relative path. To solve this problem is by adding a custom code that retrieves the relative path then concantenate with the field values that you may wish to be part of the URL - atleast that works for me.
Shaddie
回答2:
I encountered the same issue. To work around this, I created a Report Parameter called "AbsolutePath".
Go to the design view of the .rdlc file. On the "Report Data" tab, you'll see a "Parameters" node. Right click it to:
- Add Parameter...
- On the General Tab, enter "AbsolutePath" in the Name property.
- Click on "Default Values"
- Select the "Specify values" radio button.
- Add new value "AbsolutePath".
In your TextBox's Action Expression, add something like this ="javascript:void(window.open('" + Parameters!AbsolutePath.Value + "/yourpage.aspx?id=" + Fields!Id.Value + "', '_blank'))"
You can see that the new "AbsolutPath" parameter is available to add to your expression.
Now, you'll need to pass the value into the report's paramter, like so.
string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);
var param = new ReportParameter("AbsolutePath", baseUrl);
this.ReportViewer.LocalReport.SetParameters(param);
回答3:
Just use global variable Globals!ReportServerUrl
in the expression
= Globals!ReportServerUrl + "yourpath"