Friday, February 17, 2012

Error: Subreport could not be shown.

Hi,

I have been battling with this for days now and I cannot get this to work. I would really appreciate it if someone could advise me of where I am going wrong:

Default.aspx.vb:

Imports Microsoft.Reporting.WebForms

Partial Class _Default

Inherits System.Web.UI.Page

Dim odsItems As New ObjectDataSource

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf ItemsSubreportProcessingEventHandler

ReportViewer1.LocalReport.Refresh()

End Sub

Private Sub ItemsSubreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)

If odsItems Is Nothing Then

odsItems = LoadItemsData()

If (e.Parameters.Count > 0) Then

If (odsItems.SelectParameters.Count > 0) Then

odsItems.SelectParameters.RemoveAt(0)

odsItems.SelectParameters.Add(New Parameter("questionid", TypeCode.Int32, CInt(e.Parameters(0).Values(0).ToString)))

End If

End If

e.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("DataSet2_templBPQues", odsItems))

End If

End Sub

Private Function LoadItemsData()

Dim ods As New ObjectDataSource

ods.TypeName = "DataSet2TableAdapters.templBPQuesTableAdapter"

ods.SelectMethod = "GetSubQuestions"

Return ods

End Function

End Class

Default.aspx:

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@. Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"

Height="400px" Width="400px">

<LocalReport ReportPath="c:\inetpub\wwwroot\srstest\Report.rdlc">

<DataSources>

<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1_templBPQues" />

</DataSources>

</LocalReport>

</rsweb:ReportViewer>

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetQuestions"

TypeName="DataSet1TableAdapters.templBPQuesTableAdapter"></asp:ObjectDataSource>

<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetSubQuestions"

TypeName="DataSet2TableAdapters.templBPQuesTableAdapter" OldValuesParameterFormatString="original_{0}">

<SelectParameters>

<asp:Parameter Name="questionid" Type="Int32" />

</SelectParameters>

</asp:ObjectDataSource>

&nbsp;

</div>

</form>

</body>

</html>

My report is one main report with no Parameters and a subreport which is passed one parameter from the main report "questionid".

No matter what I do I get the same error: Error: Subreport could not be shown. I have tried setting the param to string, integer, hidden whatever and nothing works.

Any help would be awesome. Thanks.

Hello,

Has anyone got any clues? I have the exact same problem!

No comments:

Post a Comment