2013-07-15 81 views
0

我有一個ReportViewer控制在ASCX像這樣:的ReportViewer不會綁定

<rsweb:ReportViewer 
    Height="100%" 
    Width="100%" 
    ID="ReportViewer1" 
    runat="server" 
    AsyncRendering="False" 
    Font-Names="Verdana" 
    Font-Size="8pt" 
    WaitMessageFont-Names="Verdana" 
    WaitMessageFont-Size="14pt" 
    OnDataBinding="ReportViewer1_DataBinding" 
    OnDisposed="ReportViewer1_Disposed" 
    OnInit="ReportViewer1_Init" 
    OnLoad="ReportViewer1_Load" 
    OnReportError="ReportViewer1_ReportError"> 
</rsweb:ReportViewer> 

而在含ASCX的頁面加載:

ReportViewer1.LocalReport.DataSources.Clear(); 
int draftID = Convert.ToInt32(Session["DraftID"]); 
MyTableAdapter adapter = new MyTableAdapter(); 
var table= adapter.GetData(draftID); 
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/MyReport.rdlc"); 
var reportDataSource = new Microsoft.Reporting.WebForms.ReportDataSource("MyDataSource", (System.Data.DataTable)table); 
ReportViewer1.LocalReport.DataSources.Add(reportDataSource); 
ReportViewer1.LocalReport.Refresh(); 

我相當肯定我的網頁配置設置正確。在compilation標籤:

<buildProviders> 
     <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> 
    </buildProviders> 

而在handlers標籤(只是處理程序,爲簡便起見):

<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> 

從生成的適配器得到填補表,乍一看,看起來是正確的。我在列出的事件上設置了斷點,它將被初始化,加載,但從不綁定,導致我相信我錯過了某些明顯的事情。

任何想法?

+0

那麼reportDataSource的來源呢?調試時你檢查過了嗎? – Nithesh

+0

您的代碼一目瞭然。驗證您是否將http處理程序添加到了正確的部分。這取決於您的IIS和asp.net管道模式的版本。 – nunespascal

+0

@Nithesh - 'reportDataSource'顯示正確。來自數據表的數據正在進入數據源。 @nunespascal - 我將它添加到配置/ system.webserver/handlers - 似乎是最合乎邏輯的地方。 – Ross

回答

0

經過多次實驗,我最終從頭開始。我認爲發生的事情是我曾使用Report Builder 3構建報告,然後嘗試將RDL轉換爲RDLC。我研究過這些差異,它們很小但顯然很重要。我幾乎能夠挽救我所有的工作,只需從原始RDL複製/粘貼到具有定義的正確數據源的新RDLC。感謝您的評論和幫助。

相關問題