【问题标题】:how to add hyperlink to a column in .rdl file如何将超链接添加到 .rdl 文件中的列
【发布时间】:2018-02-22 12:40:47
【问题描述】:

我想将报表中现有的 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>

【问题讨论】:

标签: reporting-services ssrs-2008 rdlc ssrs-tablix rdl


【解决方案1】:

我的链接如下所示:

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

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

预期的可能元素列表:'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 需要如何构建的规则。

【讨论】:

  • 谢谢@McGlothlin。但是当点击超链接时,它会抛出服务器错误。错误:“/报告”应用程序中的服务器错误。无法找到该资源。说明:HTTP 404。您正在查找的资源(或其依赖项之一)可能已被删除、名称已更改或暂时不可用。请查看以下 URL 并确保其拼写正确。请求的 URL:/Reports/QuickSearch.aspx 但相同的 URL 在另一个报告中有效。
  • 使用完整 URL 重试,即资源的绝对路径。如果这不起作用,请确保您的语法正确。看看这个可以帮助你探索可能性的问题:stackoverflow.com/questions/1597258/ssrs-relative-url-hyperlink
  • 绝对路径有效。这只是有这个错误的相对路径。旧报告是使用 ssrs2005 开发的,而这个是 2008 年。您认为调用 javascript 的任何内容都应该改变吗?
  • 我们(我的团队)使用javascript:void(window.open(' .... ')) 打开一个新标签。但是,如果绝对路径有效,我怀疑问题出在您引用相对路径的方式上,这稍微超出了您提出的原始问题的范围。
  • 谢谢。将尝试对此进行更多研究,并在必要时发布不同的问题。感谢您的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-14
  • 2017-10-12
相关资源
最近更新 更多