如何将超链接添加到 .rdl 文件中的列

how to add hyperlink to a column in .rdl file

我想将报表中现有的 OrderID 列修改为超链接。所以添加了下面的<Action>代码。但它抛出以下错误。有人可以帮忙解决这个问题吗?我对使用 SSRS 报告还很陌生。 提前致谢。

错误:

Unhandled Exception: System.Web.Services.Protocols.SoapException:
System.Web.Services.Protocols.SoapException: The report definition is
not valid.  Details: The element 'Textbox' in namespace
'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'
has invalid child element 'Action' in namespace
'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'.
List of possible elements expected: 'Style, ActionInfo, Top, Left,
Height, Width, ZIndex, Visibility, ToolTip, DocumentMapLabel,
Bookmark, RepeatWith, CustomProperties, Paragraphs, CanGrow,
CanShrink, HideDuplicates, ToggleImage, UserSort, KeepTogether,
DataElementName, DataElementOutput, DataElementStyle' in namespace
'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'
as well as any element in namespace '##other'.    at
Microsoft.ReportingServices.WebServer.ReportingService2005Impl.CreateReport(String
Report, String Parent, Boolean Overwrite, Byte[] Definition,
Property[] Properties, Warning[]& Warnings)    at
Microsoft.ReportingServices.WebServer.ReportingService2005.CreateReport(String
Report, String Parent, Boolean Overwrite, Byte[] Definition,
Property[] Properties, Warning[]& Warnings)    at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall)    at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)    at
Microsoft.SqlServer.ReportingServices2005.ReportingService2005.CreateReport(String
Report, String Parent, Boolean Overwrite, Byte[] Definition,
Property[] Properties)    at
RdlSync.Repository.RemoteRdlRepository.AddRdl(IRdlFile file)    at
RdlSync.Controller.RdlReconciler.Sync(Boolean commit, Boolean useMd5,
Boolean force)    at RdlSync.Program.Main(String[] args)

.RDL文件代码:

<Body>
<ReportItems>
  <Rectangle Name="RectMain">
    <ReportItems>
      <Tablix Name="tblMainReport">
        <TablixBody>
         <TablixCell>
          <CellContents>
             <Textbox Name="orderID">
                <Action>
                     <Hyperlink>="javascript:window.location='QuickSearch.aspx?searchType=1&amp;amp;searchValue=" &amp; Fields!OrderId.Value &amp; "'"</Hyperlink>
                 </Action>
                </Textbox>
               </CellContents>
              </TablixCell>
       .....</TablixBody>
       ....
</ReportItems>
</Body>

我的链接是这样的:

<ActionInfo>
  <Actions>
    <Action>
      <Hyperlink> [link goes here] </Hyperlink>
    </Action>
  <Actions>
<ActionInfo>

这可能是您的问题,如错误中的这一行所示:

List of possible elements expected: 'Style, ActionInfo, Top, ...

我个人喜欢尽可能限制直接编辑.rdl代码,而是使用Visual Studio中的设计选项卡来修改文件。我发现如果结构不完美,更改 XML 可能很容易出错,所以我将其保存为最后的手段。

要修复 XML 结构,您必须执行如下操作:

<Textbox Name="orderID">
  <ActionInfo>
    <Actions>
      <Action>
        <Hyperlink>="javascript:window.location='QuickSearch.aspx?searchType=1&amp;amp;searchValue=" &amp; Fields!OrderId.Value &amp; "'"</Hyperlink>
      </Action>
    <Actions>
  <ActionInfo>
</Textbox>

如果您必须直接编辑代码,您很可能会发现报表定义非常有用,它在错误中有链接。它链接到 this 页面,该页面告诉您架构,即 RDL 需要如何构建的规则。