• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1181
  • Last Modified:

Report Viewer will not hide columns in local report correctly

I have a report viewer in which I have a number of columns in a local report.  In these columns I list data from a database, but depending on the part information retreived from dropdownlists that update the parameters in the local report the table requires a different number of columns.  So I have made a table with all of the columns visible and depending on this sample size (value) I hide the remain columns.

When I initially launch the page the report loads although without all of the correct columns.  When I change the parameters with the dropdownlists for a sample size greater than 1 the entire local report vanishes.  The headings and title stay visible, but the report within the reportviewer disappears.

The formula I have entered into the local report columns is as follow:
=iif(Parameters!SampleSize > 1, False, True).  This would be in the case of the 6th column.  The seventh column has 2 instead of 1 and so forth.

Below is my code from the reportviewer.
 <%@ Page Title="" Language="VB" MasterPageFile="~/ReportMaster.master" AutoEventWireup="false" CodeFile="ManualDataReport.aspx.vb" Inherits="ManualDataReport" %>

<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <asp:Panel ID="Panel1" runat="server" BackColor="#E1E1E1" BorderStyle="None" 
        Height="45px" HorizontalAlign="Left" Wrap="False" CssClass="menu">
        <br />&nbsp;
        <asp:Label ID="Label5" runat="server" Text=" Die Number: " Font-Names="Arial" Font-Size="10" 
        ForeColor="#003366"></asp:Label>
        <asp:DropDownList ID="DropDownList5" runat="server" Height="22px" Width="134px" 
            AutoPostBack="True" DataSourceID="ObjectDataSource1" DataTextField="DieNumber" 
            DataValueField="DieNumber">
        </asp:DropDownList>
        <asp:Label ID="Label4" runat="server" Text=" Part Number: " Font-Names="Arial" Font-Size="10" 
        ForeColor="#003366"></asp:Label>
        <asp:DropDownList ID="DropDownList4" runat="server" Height="22px" Width="156px" 
            AutoPostBack="True" DataSourceID="ObjectDataSource2" DataTextField="PartNumber" 
            DataValueField="PartNumber">
        </asp:DropDownList>
        <asp:Label ID="Label3" runat="server" Text=" Start Date: " Font-Names="Arial" Font-Size="10" 
        ForeColor="#003366"></asp:Label>
        <asp:DropDownList ID="DropDownList3" runat="server" Height="20px" Width="152px" 
            AutoPostBack="True" DataSourceID="ObjectDataSource4" DataTextField="Cur_Date" 
            DataValueField="Cur_Date">
        </asp:DropDownList>
        <asp:Label ID="Label2" runat="server" Text=" End Date: " Font-Names="Arial" Font-Size="10" 
        ForeColor="#003366"></asp:Label>
        <asp:DropDownList ID="DropDownList2" runat="server" Height="22px" Width="152px" 
            AutoPostBack="True" DataSourceID="ObjectDataSource4" DataTextField="Cur_Date" 
            DataValueField="Cur_Date">
        </asp:DropDownList>
    <asp:Label ID="Label1" runat="server" Text=" Metric: " Font-Names="Arial" Font-Size="10" 
        ForeColor="#003366">
        </asp:Label>
        <asp:DropDownList ID="DropDownList1" runat="server" Height="22px" Width="158px" 
            AutoPostBack="True" DataSourceID="ObjectDataSource5" DataTextField="MetricName" 
            DataValueField="MetricName">
        </asp:DropDownList>
        </asp:Panel>
        </ContentTemplate>
        <Triggers>
        <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
        <asp:AsyncPostBackTrigger ControlID="DropDownList2" EventName="SelectedIndexChanged" />
        <asp:AsyncPostBackTrigger ControlID="DropDownList3" EventName="SelectedIndexChanged" />
        <asp:AsyncPostBackTrigger ControlID="DropDownList4" EventName="SelectedIndexChanged" />
        <asp:AsyncPostBackTrigger ControlID="DropDownList5" EventName="SelectedIndexChanged" />
        </Triggers>
</asp:UpdatePanel>
        <br />
        
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
            Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
            WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" 
            AsyncRendering="False" Width="100%" SizeToReportContent="True" 
            InteractivityPostBackMode="AlwaysAsynchronous" 
        PageCountMode="Actual" ExportContentDisposition="OnlyHtmlInline"
        OnPageNavigation="ReportViewer1_PageNavigation">
            <LocalReport ReportPath="ManDataReport.rdlc" EnableExternalImages="True">
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="ObjectDataSource3" Name="DataSet1" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
        <asp:ObjectDataSource ID="ObjectDataSource3" runat="server" 
        SelectMethod="GetData" 
        TypeName="ManualDataSetTableAdapters.DataTableTableAdapter" 
        OldValuesParameterFormatString="original_{0}">
            <FilterParameters>
                <asp:ControlParameter ControlID="DropDownList5" DefaultValue="NC0117" 
                    Name="DieNumber" PropertyName="SelectedValue" />
                <asp:ControlParameter ControlID="DropDownList4" DefaultValue="27X110" 
                    Name="DieNumber" PropertyName="SelectedValue" />
            </FilterParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList5" DefaultValue="NC0117" 
                    Name="DieNumber" PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="DropDownList4" DefaultValue="27X110" 
                    Name="PartNumber" PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="DropDownList1" 
                    DefaultValue="Finish-Overall Length" Name="MetricName" 
                    PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="DropDownList3" 
                    DefaultValue="12/11/2013 9:14:45.990" Name="Cur_Date" 
                    PropertyName="SelectedValue" Type="DateTime" />
                <asp:ControlParameter ControlID="DropDownList2" 
                    DefaultValue="12/11/2013 10:48:48.990" Name="Cur_Date1" 
                    PropertyName="SelectedValue" Type="DateTime" />
            </SelectParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
        TypeName="ManualDataSetTableAdapters.PartNumberTableTableAdapter">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownList5" DefaultValue="NC0117" 
                Name="DieNumber" PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            SelectMethod="GetData" 
            TypeName="ManualDataSetTableAdapters.DataTable3TableAdapter" 
        OldValuesParameterFormatString="original_{0}">
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="ObjectDataSource4" runat="server" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
            TypeName="ManualDataSetTableAdapters.DataTable2TableAdapter">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList5" DefaultValue="NC0117" 
                    Name="DieNumber" PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="DropDownList4" DefaultValue="27X110" 
                    Name="PartNumber" PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="ObjectDataSource5" runat="server" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
            TypeName="ManualDataSetTableAdapters.MetricNameTableTableAdapter">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList5" DefaultValue="NC0117" 
                    Name="DieNumber" PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="DropDownList4" DefaultValue="27X110" 
                    Name="PartNumber" PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
        
</asp:Content>

Open in new window

Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WebForms
Imports Microsoft.Reporting.WebForms.PageNavigationEventArgs
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.DropDownList




Partial Class ManualDataReport
    Inherits System.Web.UI.Page

        Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Dim LoginSessionID As String = Session("Login")

        ReportViewer1.LocalReport.ReportPath = "ManDataReport.rdlc"
        Dim LoginIDParam As Microsoft.Reporting.WebForms.ReportParameter
        LoginIDParam = New Microsoft.Reporting.WebForms.ReportParameter("LoginID", "Prepared By: " & Session("Login").ToString)
        Me.ReportViewer1.LocalReport.SetParameters(LoginIDParam)
        Me.ReportViewer1.LocalReport.Refresh()
        If Not IsPostBack Then
            
            DropDownList5.SelectedValue = "NC0118"
            DropDownList4.SelectedValue = "15-94"
            UpdatePanel1.Update()
        Else
        End If
        If (IsPostBack) Then
            UpdatePanel1.Update()
        End If
    
        Dim PtNoConStr As String = "Data Source=...nual_Data"
        Dim PtCon As SqlConnection = New SqlConnection(PtNoConStr)

        Dim PtNoCmd As New SqlCommand("SELECT SubgroupSize FROM ChartType WHERE PartNumber=@PartNumber AND MetricName=@MetricName")
        PtNoCmd.Parameters.AddWithValue("@PartNumber", DropDownList4.SelectedValue)
        PtNoCmd.Parameters.AddWithValue("@MetricName", DropDownList1.SelectedValue)
        PtCon.Open()
        PtNoCmd.Connection = PtCon
        Dim SampleSize As Integer = PtNoCmd.ExecuteScalar()
        PtCon.Close()
        PtCon.Dispose()
        PtNoCmd.Dispose()
    
        Dim SampSizeParam As Microsoft.Reporting.WebForms.ReportParameter
        SampSizeParam = New Microsoft.Reporting.WebForms.ReportParameter("SampleSize", SampleSize)
        Me.ReportViewer1.LocalReport.SetParameters(SampSizeParam)
        Me.ReportViewer1.LocalReport.Refresh()

    End Sub
    Protected Sub ReportViewer1_PageNavigation(sender As Object, e As Microsoft.Reporting.WebForms.PageNavigationEventArgs)
        ReportViewer1.CurrentPage = e.NewPage
    End Sub
    Protected Sub DropDownList5_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DropDownList5.SelectedIndexChanged
        DropDownList4.DataBind()
        ReportViewer1.LocalReport.ReportPath = "ManDataReport.rdlc"
        Dim DieNumberParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim PartNumberParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim MetricNameParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim FirstDateParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim SecondDateParam As Microsoft.Reporting.WebForms.ReportParameter
        DieNumberParam = New Microsoft.Reporting.WebForms.ReportParameter("DieNumberParameter", DropDownList5.SelectedValue.ToString)
        PartNumberParam = New Microsoft.Reporting.WebForms.ReportParameter("PartNumber", DropDownList4.SelectedValue.ToString)
        MetricNameParam = New Microsoft.Reporting.WebForms.ReportParameter("MetricName", DropDownList1.SelectedValue.ToString)
        FirstDateParam = New Microsoft.Reporting.WebForms.ReportParameter("FirstDate", DropDownList3.SelectedValue)
        Dim DateValue As DateTime = FormatDateTime(DropDownList2.SelectedValue, DateFormat.GeneralDate)


DieNumber = '" & DropDownList5.SelectedValue & "' AND PartNumber = '" & DropDownList4.SelectedValue & "' AND MetricName = '" & DropDownList1.SelectedValue & "'")
        SecondDateParam = New Microsoft.Reporting.WebForms.ReportParameter("SecondDate", DateValue) 'DropDownList2.SelectedValue)


        Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "ManDataReport.rdlc"
        Me.ReportViewer1.LocalReport.ReportPath = "ManDataReport.rdlc"

        Me.ReportViewer1.LocalReport.SetParameters(DieNumberParam)
        Me.ReportViewer1.LocalReport.SetParameters(PartNumberParam)
        Me.ReportViewer1.LocalReport.SetParameters(MetricNameParam)
        Me.ReportViewer1.LocalReport.SetParameters(FirstDateParam)
        Me.ReportViewer1.LocalReport.SetParameters(SecondDateParam)


        Me.ReportViewer1.LocalReport.Refresh()

    End Sub
    Protected Sub DropDownList4_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DropDownList4.SelectedIndexChanged

        ReportViewer1.LocalReport.ReportPath = "ManDataReport.rdlc"
        Dim DieNumberParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim PartNumberParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim MetricNameParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim FirstDateParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim SecondDateParam As Microsoft.Reporting.WebForms.ReportParameter
        DieNumberParam = New Microsoft.Reporting.WebForms.ReportParameter("DieNumberParameter", DropDownList5.SelectedValue.ToString)
        PartNumberParam = New Microsoft.Reporting.WebForms.ReportParameter("PartNumber", DropDownList4.SelectedValue.ToString)
        MetricNameParam = New Microsoft.Reporting.WebForms.ReportParameter("MetricName", DropDownList1.SelectedValue.ToString)
        FirstDateParam = New Microsoft.Reporting.WebForms.ReportParameter("FirstDate", DropDownList3.SelectedValue)
        SecondDateParam = New Microsoft.Reporting.WebForms.ReportParameter("SecondDate", DropDownList2.SelectedValue)



        Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "ManDataReport.rdlc"
        Me.ReportViewer1.LocalReport.ReportPath = "ManDataReport.rdlc"

        Me.ReportViewer1.LocalReport.SetParameters(DieNumberParam)
        Me.ReportViewer1.LocalReport.SetParameters(PartNumberParam)
        Me.ReportViewer1.LocalReport.SetParameters(MetricNameParam)
        Me.ReportViewer1.LocalReport.SetParameters(FirstDateParam)
        Me.ReportViewer1.LocalReport.SetParameters(SecondDateParam)



        Dim NewPtNumber As String = DropDownList4.SelectedValue


        Me.ReportViewer1.LocalReport.Refresh()


    End Sub
    Protected Sub DropDownList3_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DropDownList3.SelectedIndexChanged

        ReportViewer1.LocalReport.ReportPath = "ManDataReport.rdlc"
        Dim DieNumberParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim PartNumberParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim MetricNameParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim FirstDateParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim SecondDateParam As Microsoft.Reporting.WebForms.ReportParameter
        DieNumberParam = New Microsoft.Reporting.WebForms.ReportParameter("DieNumberParameter", DropDownList5.SelectedValue.ToString)
        PartNumberParam = New Microsoft.Reporting.WebForms.ReportParameter("PartNumber", DropDownList4.SelectedValue.ToString)
        MetricNameParam = New Microsoft.Reporting.WebForms.ReportParameter("MetricName", DropDownList1.SelectedValue.ToString)
        FirstDateParam = New Microsoft.Reporting.WebForms.ReportParameter("FirstDate", DropDownList3.SelectedValue)
        SecondDateParam = New Microsoft.Reporting.WebForms.ReportParameter("SecondDate", DropDownList2.SelectedValue)


        Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "ManDataReport.rdlc"
        Me.ReportViewer1.LocalReport.ReportPath = "ManDataReport.rdlc"

        Me.ReportViewer1.LocalReport.SetParameters(DieNumberParam)
        Me.ReportViewer1.LocalReport.SetParameters(PartNumberParam)
        Me.ReportViewer1.LocalReport.SetParameters(MetricNameParam)
        Me.ReportViewer1.LocalReport.SetParameters(FirstDateParam)
        Me.ReportViewer1.LocalReport.SetParameters(SecondDateParam)



        Me.ReportViewer1.LocalReport.Refresh()

    End Sub
    Protected Sub DropDownList2_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged

        ReportViewer1.LocalReport.ReportPath = "ManDataReport.rdlc"
        Dim DieNumberParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim PartNumberParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim MetricNameParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim FirstDateParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim SecondDateParam As Microsoft.Reporting.WebForms.ReportParameter
        DieNumberParam = New Microsoft.Reporting.WebForms.ReportParameter("DieNumberParameter", DropDownList5.SelectedValue.ToString)
        PartNumberParam = New Microsoft.Reporting.WebForms.ReportParameter("PartNumber", DropDownList4.SelectedValue.ToString)
        MetricNameParam = New Microsoft.Reporting.WebForms.ReportParameter("MetricName", DropDownList1.SelectedValue.ToString)
        FirstDateParam = New Microsoft.Reporting.WebForms.ReportParameter("FirstDate", DropDownList3.SelectedValue)
        SecondDateParam = New Microsoft.Reporting.WebForms.ReportParameter("SecondDate", DropDownList2.SelectedValue)


        Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "ManDataReport.rdlc"
        Me.ReportViewer1.LocalReport.ReportPath = "ManDataReport.rdlc"

        Me.ReportViewer1.LocalReport.SetParameters(DieNumberParam)
        Me.ReportViewer1.LocalReport.SetParameters(PartNumberParam)
        Me.ReportViewer1.LocalReport.SetParameters(MetricNameParam)
        Me.ReportViewer1.LocalReport.SetParameters(FirstDateParam)
        Me.ReportViewer1.LocalReport.SetParameters(SecondDateParam)


        Me.ReportViewer1.LocalReport.Refresh()

    End Sub
    Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

        ReportViewer1.LocalReport.ReportPath = "ManDataReport.rdlc"
        Dim DieNumberParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim PartNumberParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim MetricNameParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim FirstDateParam As Microsoft.Reporting.WebForms.ReportParameter
        Dim SecondDateParam As Microsoft.Reporting.WebForms.ReportParameter
        DieNumberParam = New Microsoft.Reporting.WebForms.ReportParameter("DieNumberParameter", DropDownList5.SelectedValue.ToString)
        PartNumberParam = New Microsoft.Reporting.WebForms.ReportParameter("PartNumber", DropDownList4.SelectedValue.ToString)
        MetricNameParam = New Microsoft.Reporting.WebForms.ReportParameter("MetricName", DropDownList1.SelectedValue.ToString)
        FirstDateParam = New Microsoft.Reporting.WebForms.ReportParameter("FirstDate", DropDownList3.SelectedValue)
        SecondDateParam = New Microsoft.Reporting.WebForms.ReportParameter("SecondDate", DropDownList2.SelectedValue)


        Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "ManDataReport.rdlc"
        Me.ReportViewer1.LocalReport.ReportPath = "ManDataReport.rdlc"

        Me.ReportViewer1.LocalReport.SetParameters(DieNumberParam)
        Me.ReportViewer1.LocalReport.SetParameters(PartNumberParam)
        Me.ReportViewer1.LocalReport.SetParameters(MetricNameParam)
        Me.ReportViewer1.LocalReport.SetParameters(FirstDateParam)
        Me.ReportViewer1.LocalReport.SetParameters(SecondDateParam)
        Me.ReportViewer1.LocalReport.Refresh()

    End Sub

End Class

Open in new window

0
rckrch
Asked:
rckrch
  • 4
1 Solution
 
deepu chandranCommented:
HI,

In all your Dropdown list "SelectedIndexChanged" event you have to Load the datasource again, then you have to refresh


ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(ObjectDataSource3)
ReportViewer1.LocalReport.Refresh()

My syntax may be wrong, i have not done much vb.net code.

Thanks
Deepu
0
 
rckrchAuthor Commented:
deepu chandarin,

Thanks for the reply.  Sorry it took me so long to get back to you, but I get an immediate error when I put this code in:

Value of type 'System.Web.UI.WebControls.ObjectDataSource' cannot be converted to 'Microsoft.Reporting.WebForms.ReportDataSource'.
0
 
rckrchAuthor Commented:
deepu chandarin,

I really don't understand.  If I have generated the data source in the adp.net code do I have to regenerate a new data source and table every time I change one of the drop down boxes?

I can get the report to come up each time with the dropdownbox changes as long as the sample size stays at 1.  I just can't get the extra columns needed for the sample sizes greater than 1.

Any ideas?

Thanks again for the reply.
0
 
rckrchAuthor Commented:
I found the problem.  I had added a parameter that used a separate dataset and did not complete the proper linking of the data set to the parameter in the .rdlc control.
0
 
rckrchAuthor Commented:
I identified the solution on my own.  No sufficient reply from experts.
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now