[英]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. 我已使用.NET Framework 4.5在VS 2012中创建了ASP.NET空Web应用程序。 I have also added a report to this project.
我还向该项目添加了报告。 Inside the Web.Config I have set my connection string.
在Web.Config内部,我已经设置了连接字符串。
When working on the report I do not have an option to add a DataSource like I do when working in Windows Form Application. 处理报表时,没有像在Windows窗体应用程序中那样添加数据源的选项。 I want to connect this web app to a object from a library.
我想将此Web应用程序连接到库中的对象。
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 dt
将是您的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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.