Question

I've written a simple webForm that contains 1 textbox and a ReportViewer (created by Reoprt Wizard). I'm receiving no errors when attempting to execute the report, but the report never stops loading. I've double checked the .rdlc file (by previewing the .xsd file and it displays the expected data. So, I set up a breakpoint in my code behind to see if I could identify the problem. Somehow, the code successfully completes and refreshes the ReportViewer code, and then goes into a Designer.vb file to run 4 functions, and then back to the ReportViewer code again. I don't understand what is happening in the Designer.vb code. Could someone please help me understand what I've done wrong? I'll include the ASP.net, vb code behind, and the 4 blocks of code from the Designer.vb file.

ASP.net Code:

    <%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/HRMaster.Master" CodeBehind="VacationSick_EmployeeReportByArea.aspx.vb" Inherits="CEI_PerformanceReviews.VacationSick_EmployeeReportByArea" %>
    <%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HRPlaceHolder" runat="server">
    <asp:Label ID="Label2" runat="server" style="z-index: 1; left: 74px; top: 215px; position: absolute" Text="Year:"></asp:Label>
    <p>
    </p>
    <asp:DropDownList ID="ddl_Year" runat="server" DataSourceID="YearChooser" DataTextField="PeriodYYYY" DataValueField="PeriodYYYY" style="z-index: 1; left: 129px; top: 214px; position: absolute">
    </asp:DropDownList>
    <asp:SqlDataSource ID="YearChooser" runat="server" ConnectionString="<%$ ConnectionStrings:CafeWorksConnectionString %>" SelectCommand="SELECT  DISTINCT PeriodYYYY
FROM    Ted.CafeWorks.dbo.FatzPeriodDates
WHERE   PeriodYYYY &gt;= (DATEPART(YEAR, GetDate())-2)
ORDER BY PeriodYYYY DESC"></asp:SqlDataSource>
    <asp:Button ID="btn_Refresh" runat="server" style="z-index: 1; left: 269px; top: 212px; position: absolute" Text="Refresh" />
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="XX-Large" ForeColor="#000099" style="z-index: 1; left: 0px; top: 142px; position: absolute; width: 1179px; text-align: center" Text="Employee Vacation/Sick Days by Area Report"></asp:Label>
    <rsweb:ReportViewer ID="rv_EmployeeReportByArea" runat="server" Font-Names="Verdana" Font-Size="8pt" style="z-index: 1; left: 29px; top: 280px; position: absolute; height: 400px; width: 710px" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
        <LocalReport ReportEmbeddedResource="CEI_PerformanceReviews.VacationSick_ReportByArea.rdlc">
            <DataSources>
                <rsweb:ReportDataSource DataSourceId="ObjectDataSource2" Name="Dilbert_VacationSickByArea" />
            </DataSources>
        </LocalReport>
    </rsweb:ReportViewer>
    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetData" TypeName="CEI_PerformanceReviews.Dilbert_VacationSickByAreaTableAdapters.VacationSick_CalculationsByAreaProcTableAdapter" OldValuesParameterFormatString="original_{0}">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddl_Year" DefaultValue="2014" Name="Year" PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="CEI_PerformanceReviews.Dilbert_VacationSickByAreaTableAdapters.VacationSick_CalculationsByAreaProcTableAdapter" OldValuesParameterFormatString="original_{0}">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddl_Year" Name="Year" PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
</asp:Content>

VB Code Behind:

Imports Microsoft.Reporting.WebForms

Public Class VacationSick_EmployeeReportByArea
Inherits System.Web.UI.Page

'Declare Variables
Dim Choose_Year As String

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    'Default the Year in ddl to this year
    If (Page.IsPostBack) = False Then
        ddl_Year.SelectedValue = Now.Year
    End If

    'When the page loads, fill the report with the current year's data
    Choose_Year = ddl_Year.SelectedValue.ToString()
    rv_EmployeeReportByArea.LocalReport.ReportPath = "VacationSick\VacationSick_ReportByArea.rdlc"
    Dim Param As New ReportParameter("Year", "2014")
    rv_EmployeeReportByArea.LocalReport.SetParameters({Param})
    rv_EmployeeReportByArea.ServerReport.Refresh()
End Sub

These 4 Code Blocks from the file Dilbert_VacationSickByArea.Designer.vb are executed and then it goes back to the PageLoad code for the ReportViewer:

<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")>  _
        Public Property ClearBeforeFill() As Boolean
            Get
                Return Me._clearBeforeFill
            End Get
            Set
                Me._clearBeforeFill = value
            End Set
        End Property


 <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")>  _
        Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter
            Get
                If (Me._adapter Is Nothing) Then
                    Me.InitAdapter
                End If
                Return Me._adapter
            End Get
        End Property


 <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")>  _
        Protected ReadOnly Property CommandCollection() As Global.System.Data.SqlClient.SqlCommand()
            Get
                If (Me._commandCollection Is Nothing) Then
                    Me.InitCommandCollection
                End If
                Return Me._commandCollection
            End Get
        End Property


 <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")>  _
        Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter
            Get
                If (Me._adapter Is Nothing) Then
                    Me.InitAdapter
                End If
                Return Me._adapter
            End Get
        End Property


 <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")>  _
        Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter
            Get
                If (Me._adapter Is Nothing) Then
                    Me.InitAdapter
                End If
                Return Me._adapter
            End Get
        End Property
Was it helpful?

Solution

Try printing your report only If Not Me.Page.IsPostBack.

You can also remove rv_EmployeeReportByArea.ServerReport.Refresh() because you're using a LocalReport.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top