Pass parameter to rdlc from page with reportviewer

£可爱£侵袭症+ 提交于 2019-12-11 17:15:13

问题


I have a visual studio 2013 web application which works with entity framework and I want to display a simple tabular data report using a RDLC report.

I have created a seperate web page and added a reportviewer control. Also I have created a RDLC file and added the data source from a C# function which returns a List of custom objects. This way it is configurable from the report designer, but when the page loads in the browser an error A data source instance has not been supplied for the data source 'DataSet1' is shown.

Report design

HTML markup

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

For above implementation I got the error of not giving a data source, but as Yuliam Chandra suggested, I added the below code and now the report works.

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

Please help me to solve this issue. I just need to display a simple report using RDLC and the data source is a public static function with an argument which returns a list of objects.


回答1:


Have you set the data source in the page load?

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


来源:https://stackoverflow.com/questions/24969018/pass-parameter-to-rdlc-from-page-with-reportviewer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!