Render RDLC as a PDF, with a HyperLink

泄露秘密 提交于 2019-12-24 11:27:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!