簡體   English   中英

使用reportviewer將參數從頁面傳遞到rdlc

[英]Pass parameter to rdlc from page with reportviewer

我有一個Visual Studio 2013 Web應用程序,可與實體框架一起使用,我想使用RDLC報告顯示簡單的表格數據報告。

我創建了一個單獨的網頁並添加了reportviewer控件。 另外,我還創建了RDLC文件,並從C#函數添加了數據源,該函數返回了自定義對象的List 通過這種方式,可以從報表設計器進行配置,但是當頁面在瀏覽器中加載時,將顯示錯誤A data source instance has not been supplied for the data source 'DataSet1'

報告設計 在此處輸入圖片說明

HTML標記

    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
        WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
        <LocalReport ReportPath="Alumni\Reports\Report1.rdlc"></LocalReport>
    </rsweb:ReportViewer>

對於上面的實現,我遇到了不提供數據源的錯誤,但是正如Yuliam Chandra所建議的那樣,我添加了以下代碼,現在報告可以工作了。

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", Business.ReportManager.GetMemberDetails(1)));
        }
    }

請幫我解決這個問題。 我只需要顯示一個使用RDLC的簡單報告,數據源是一個公共靜態函數,帶有一個返回對象列表的參數。

您是否在頁面加載中設置了數據源?

YourReportViewer.LocalReport.DataSources.Add(new ReportDataSource("testDataSet", list));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM