none
Using ReportViewer 2010 inside a multiview RRS feed

  • Question

  • Hi, I am using the ReportViewer 2010 control inside a multiview. However, to show the report it seems like I have to call the SetParameters function even if the Report doesn't have any parameters. Any ideas on why this is needed? ReportViewer.LocalReport.Refresh doesn't work, nor does ReportViewer.DataBind.

    Default.aspx

    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
      CodeBehind="Default.aspx.cs" Inherits="ReportViewerInMultiView._Default" %>
    
    <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
      Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
    
    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    </asp:Content>
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
      <asp:ScriptManager ID="ScriptManager1" runat="server">
      </asp:ScriptManager>
      <asp:Button ID="btn" runat="server" OnClick="btn_Click" Text="Click" /><br />
      <asp:MultiView runat="server" ID="multiView">
        <asp:View runat="server" ID="view1">
          View 1
        </asp:View>
        <asp:View runat="server" ID="view2">
          View 2
          <rsweb:ReportViewer ID="ReportViewer1" runat="server">
            <LocalReport ReportPath="Reports\Dummy.rdlc">
            </LocalReport>
          </rsweb:ReportViewer>
        </asp:View>
      </asp:MultiView>
    </asp:Content>
    

    Default.aspx.cs

    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;
    
    namespace ReportViewerInMultiView
    {
      public partial class _Default : System.Web.UI.Page
      {
        protected void Page_Load(object sender, EventArgs e)
        {
          if (!IsPostBack)
            multiView.SetActiveView(view1);
        }
    
        protected void btn_Click(object sender, EventArgs e)
        {
          multiView.SetActiveView(view2);
          // TODO: It seems I have to call LocalReport.SetParameters(...) to show the report when in a multiview.
          // LocalReport.Refresh doesn't do the trick, nor does ReportViewer.DataBind
          ReportViewer1.LocalReport.SetParameters(new ReportParameter());
        }
      }
    }
    
    Thursday, August 19, 2010 9:25 AM

All replies

  • Thank you so much for posting your workaround. This is exactly the issue we were having in migrating to ReportViewer 10. Although I agree that the fix makes no sense to us, we are very grateful to benefit from your experimentation.

    It would be great if there was more documentation out there for this tool.

     

    Cheers!

    Tuesday, August 24, 2010 1:30 PM
  • I was having the same exact problem, thanks for the solution!
    Monday, June 4, 2012 2:09 PM
  • thank you
    Sunday, November 27, 2016 10:44 PM