TechSapphire Sunday, 2018-12-16, 5:51 PM
Site menu
Login form
News
Play Games
  • Deep Freeze
  • Ice Slide
  • Gyroball
  • Fat Fish
  • Bush Royal Rampage
  • Error: Subreport could not be shown. RDLC using with ASP.NET.

    This exception is thrown only in 3 cases:
    1. Parameter is not passed to sub report
    2. Parameter which is been passed is not been created on sub report
    3. Data type of parameter on main report and sub report is not matching up.

    C# code which is required to display sub report is mentioned below:

    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;
    public partial class ReportForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ObjectDataSource obj = new ObjectDataSource();
                obj.TypeName = "NorthWindDataSetTableAdapters.CustomersTableAdapter";
                obj.SelectMethod = "GetData";
                ReportViewer1.LocalReport.ReportPath = "Report.rdlc";
                ReportDataSource objSource=new ReportDataSource("DataSet1",obj);
                ReportViewer1.LocalReport.DataSources.Add(objSource);
                ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(localReport_SubreportProcessing);
                ReportViewer1.LocalReport.Refresh();
            }
        }
        void localReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
        {
            ObjectDataSource obj = new ObjectDataSource();
            obj.TypeName = "NorthWindDataSetTableAdapters.OrdersTableAdapter";
            obj.SelectMethod = "GetData";
            obj.SelectParameters.Add("CustomerID", e.Parameters["CustomerID"].Values.First());
            ReportDataSource objSource = new ReportDataSource("DataSet1", obj);
            e.DataSources.Add(objSource);
        }
    }

    To download project click here.

    Categories
    Programming [27]
    Tips for programming
    Security [2]
    Security Tips
    Google [1]
    Use google faster then ever you use
    Project [14]
    HTML [2]
    Electronics [0]
    Data Structure [0]
    Database [16]
    SQL SERVER
    SSRS [1]
    Sql Server Reporting Services
    Copyright MyCorp © 2018