Hi,
I am trying to create a report in a web application. The report is supposed to have a sub report in it.
What I did was create 2 reports.
Report1 (Master Report)
Report2 (SubReport)
I added parameters to the reports. then I dropped a subreport control on the report1. and set its properties to reference to Report2.
I also set the parameter for the subreport.
But it gave me the error
Data retrieval failed for the subreport, 'Subreport1', located at:Path \Report2.rdlc. Please check the log files for more information. |
The Code is below
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:TextBox ID="TextBox1" runat="server">2</asp:TextBox><asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /><rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="636px" Height="397px" style="margin-right: 0px"><LocalReport ReportPath="Report1.rdlc"><DataSources><rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" /><rsweb:ReportDataSource DataSourceId="ObjectDataSource2" Name="DataSet2" /></DataSources></LocalReport></rsweb:ReportViewer><asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="PRMSReports.PRMSReportsTableAdapters.ExpenditureViewTableAdapter"><SelectParameters><asp:ControlParameter ControlID="TextBox1" DefaultValue="2" Name="projectid" PropertyName="Text" Type="Int32" /></SelectParameters></asp:ObjectDataSource><asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="PRMSReports.PRMSReportsTableAdapters.Project_ProfileTableAdapter" UpdateMethod="Update"><DeleteParameters><asp:Parameter Name="Original_Project_ID" Type="Int32" /></DeleteParameters><InsertParameters><asp:Parameter Name="Project_Title" Type="String" /></InsertParameters><SelectParameters><asp:ControlParameter ControlID="TextBox1" DefaultValue="2" Name="projectid" PropertyName="Text" Type="Int32" /></SelectParameters><UpdateParameters><asp:Parameter Name="Project_Title" Type="String" /><asp:Parameter Name="Original_Project_ID" Type="Int32" /></UpdateParameters></asp:ObjectDataSource>
the code behind file has the following code
protected void Page_Load(object sender, EventArgs e) { ReportViewer1.LocalReport.SubreportProcessing += SetSubDataSource; //this.ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessingEventHandler); this.ReportViewer1.LocalReport.ShowDetailedSubreportMessages = true; this.ReportViewer1.LocalReport.Refresh(); } protected void Button1_Click(object sender, EventArgs e) { string name = TextBox1.Text; ObjectDataSource1.SelectParameters["projectid"].DefaultValue = name; ObjectDataSource1.DataBind(); ReportViewer1.LocalReport.SubreportProcessing += SetSubDataSource; this.ReportViewer1.LocalReport.Refresh(); } protected void SetSubDataSource(object sender, SubreportProcessingEventArgs e) { int Per_ID = Convert.ToInt32(TextBox1.Text); ExpenditureViewTableAdapter dt1 = new ExpenditureViewTableAdapter(); dynamic rds = new ReportDataSource(); rds.Name = "DataSet2"; rds.Value = dt1.GetData(Per_ID); e.DataSources.Add(rds); }
Please note that i am trying to do this in a web application and not a report project. Help Needed.
Thanks