简体   繁体   中英

ASP.NET ReportViewer Datasource connectionstring not supplied from web.Config

I have created an ASP.NET Empty Web Application in VS 2012 using the .NET Framework 4.5. I have also added a report to this project. Inside the Web.Config I have set my connection string.

When working on the report I do not have an option to add a DataSource like I do when working in Windows Form Application. I want to connect this web app to a object from a library.

Edit: Why can we not access Object Datasource Type when the a library reference is added to the project? Why does a helper class have to be added to access the library objects. Here is what has to be done to achieve this: here

You can do it programmatically:

ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt));

dt would be your dataTable

EDIT:

<rsweb:ReportViewer ID="ReportViewer1" runat="server">
    <LocalReport ReportEmbeddedResource="Report1.rdlc" ReportPath="Report1.rdlc">
        <DataSources>
            <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
        </DataSources>
    </LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server">
</asp:ObjectDataSource>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM