问题
I have a requirement to add a Hyperlink to a PDF report (RDLC). The report renders fine before adding the HyperLink (generated via .NET, using parameters and datasets).
To make a 'proof of concept' in code I have added
ReportViewer1.LocalReport.EnableHyperlinks = True
ReportViewer1.HyperlinkTarget = "_Blank"
In the RDLC I have added a TextBox, added an Action 'Go to URL' and set the URL as 'http://www.google.com'
When rendering I get
An error occurred during local report processing
When I then have a look into the error in more depth, the innerException is
One or more parameters required to run the report have not been specified.
What am I missing?
回答1:
Okay, not ideal, but I ended up editing the RDLC in XML, not via the VisualStudio UI and got it working.
I've then swapped the hardcoded URL, to a Parameter
VS must not be setting something required. I added the following to the Root of the Object's XML, just after 'Paragraphs'.
</Paragraphs>
<ActionInfo>
<Actions>
<Action>
<Hyperlink>=Parameters!HyperlinkURL.Value</Hyperlink>
</Action>
</Actions>
</ActionInfo>
And then, the Parameter added under 'ReportParameters'
<ReportParameters>
<ReportParameter Name="HyperlinkURL">
<DataType>String</DataType>
<Nullable>true</Nullable>
<AllowBlank>true</AllowBlank>
<Prompt>HyperlinkURL</Prompt>
</ReportParameter>
来源:https://stackoverflow.com/questions/52865434/render-rdlc-as-a-pdf-with-a-hyperlink