在StackOverFlow:SSRS Subreport VS2010 data retrieval failed for the subreport中阅读此帖子之后,我仍然得到"数据检索失败的子报告"。主要报告和子报告在BIDS 2008中运行良好,因此我的.cs或.aspx页面必须出错。我使用的代码如下。谁能告诉我我做错了什么?谢谢!
aspx页面:
<asp:DropDownList ID="DropDownListVisit" runat="server" DataTextField="VisitList"
DataValueField="VisitID" AutoPostBack="True" AppendDataBoundItems="true"
onselectedindexchanged="DropDownListVisit_SelectedIndexChanged"
DataSourceID="EntityDataSourceVisitDropDown">
<asp:ListItem Text="--- Select Ship & Visit ---" Value="" Selected="True"></asp:ListItem>
</asp:DropDownList>
<asp:EntityDataSource ID="EntityDataSourceVisitDropDown" runat="server"
ConnectionString="name=Admiral_NSSAEntities"
DefaultContainerName="Admiral_NSSAEntities" EnableFlattening="False"
EntitySetName="vw_VisitList"
Select="it.[VisitID], it.[VisitList], it.[ShipName], it.[StartDate]"
OrderBy="it.[ShipName] asc, it.[StartDate] desc">
</asp:EntityDataSource>
<rsweb:ReportViewer ID="ReportViewerSummeryReportOutBrief" runat="server" Font-Names="Verdana"
Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="1139px"
Height="894px" PageCountMode="Actual" PromptAreaCollapsed="True"
style="margin-right: 0px">
<LocalReport ReportPath="Secured\Reports\SummeryReportOutBrief.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="EntityDataSourceVisitInfo"
Name="VisitInfo" />
<rsweb:ReportDataSource DataSourceId="EntityDataSourceWorkOrders"
Name="WorkOrders" />
<rsweb:ReportDataSource DataSourceId="EntityDataSourcePartsDataByWorkOrder"
Name="PartsDataByWorkOrder" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:EntityDataSource ID="EntityDataSourcePartsDataByWorkOrder" runat="server"
ConnectionString="name=Admiral_NSSAEntities"
DefaultContainerName="Admiral_NSSAEntities" EnableFlattening="False"
EntitySetName="vw_PartsDataByWorkOrder" >
</asp:EntityDataSource>
<asp:EntityDataSource ID="EntityDataSourceWorkOrders" runat="server"
AutoGenerateOrderByClause="True" AutoGenerateWhereClause="True"
ConnectionString="name=Admiral_NSSAEntities"
DefaultContainerName="Admiral_NSSAEntities" EnableFlattening="False"
EntitySetName="vw_WorkOrders" Where="">
<WhereParameters>
<asp:ControlParameter ControlID="DropDownListVisit" DbType="Guid"
Name="VisitID" PropertyName="SelectedValue" />
</WhereParameters>
</asp:EntityDataSource>
<asp:EntityDataSource ID="EntityDataSourceVisitInfo" runat="server"
AutoGenerateOrderByClause="True" AutoGenerateWhereClause="True"
ConnectionString="name=Admiral_NSSAEntities"
DefaultContainerName="Admiral_NSSAEntities" EnableFlattening="False"
EntitySetName="vw_VisitInfo" Where="">
<WhereParameters>
<asp:ControlParameter ControlID="DropDownListVisit" DbType="Guid"
Name="VisitID" PropertyName="SelectedValue" />
</WhereParameters>
</asp:EntityDataSource>
</asp:Content>
代码背后:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using System.Configuration;
public partial class Secured_Reports_SummeryReportOutBriefAll : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (DropDownListVisit.SelectedValue == "")
{
this.ReportViewerSummeryReportOutBrief.Visible = false;
ReportViewerSummeryReportOutBrief.LocalReport.Refresh();
ReportViewerSummeryReportOutBrief.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessingEventHandler);
}
}
public void SubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
{
e.DataSources.Add(new ReportDataSource("PartsDataByWorkOrder", this.EntityDataSourcePartsDataByWorkOrder));
}
protected void DropDownListVisit_SelectedIndexChanged(object sender, EventArgs e)
{
//In App_Code _TemplateFiles
Reports.ShowReport(this.DropDownListVisit, this.ReportViewerSummeryReportOutBrief);
}
}