2017-09-13 139 views
1

我想修改報告中現有的OrderID列作爲超鏈接。因此添加了以下代碼<Action>。但它拋出以下錯誤。有人可以幫助這一點。我在使用SSRS報告方面相當新。 在此先感謝。如何將超鏈接添加到.rdl文件中的列

錯誤

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> 
+0

不要忘了該報告的EnableHyperlinks屬性設置爲true - https://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.localreport.enablehyperlinks.aspx – InitK

回答

2

我的鏈接看起來是這樣的:

<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如何構建的規則。

+0

感謝@McGlothlin。但是當點擊超鏈接時,它會拋出服務器錯誤。 錯誤: '/ Reports'應用程序中的服務器錯誤。 無法找到該資源。 描述:HTTP 404.您正在查找的資源(或其某個依賴項)可能已被刪除,名稱已更改或暫時不可用。請檢查以下網址並確保它拼寫正確。 請求的網址:/Reports/QuickSearch.aspx 但是相同的網址在其他報告中工作。 – ranp

+0

請嘗試使用完整網址,即資源的絕對路徑。如果這不起作用,請確保您的語法正確。看看這個問題,這可能會幫助你探索可能性:https://stackoverflow.com/questions/1597258/ssrs-relative-url-hyperlink – McGlothlin

+0

絕對路徑的作品。這只是具有此錯誤的相對路徑。舊報告是使用ssrs2005開發的,而這個是2008年。你認爲任何與調用javascript應該改變? – ranp

相關問題