We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Report Viewer in MVC app problem.

Thread ID:

Created:

Updated:

Platform:

Replies:

115705 Jan 31,2014 12:15 AM Feb 3,2014 02:02 AM ASP.NET MVC (Classic) 2
loading
Tags: ReportViewer
brian@hawktech.us
Asked On January 31, 2014 12:15 AM

Hi,
I'm trying to create an MVC razor view page with a list of reports on the left and a Report Viewer control on the right.  The reports will be SSRS (.rdlc) reports.  When the user clicks a link on the left, the report viewer should display a certain report.  I haven't found  an example of this type of functionality yet.  All examples I've seen are related to displaying 1 report when the page loads.  Does something like this exist?

In the mean time, I am attempting to even load 1 hard coded report when the page loads.  The result is the page loads, I see the report viewer toolbar, and a continuously spinning icon.  The spinning icon does not go away.  Any ideas what might be going on here?  I appreciate any guidance you might have.



brian@hawktech.us
Replied On January 31, 2014 12:54 AM

This is my code for trying to get just one report running (which just gives toolbar and spinning icon).  

Controller Code (In debug I can see that the datasources object is populating with the 3 datasets)

        //this is the default view that gets called
        public ActionResult ProjectReports(string externalstring)
        {
            ViewData["ReportModel"] = this.GetSSRSModel();
            return View();
        }

       [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult SSRS(ReportViewerParams param)
        {
            return new ReportViewerHtmlActionResult(this.GetSSRSModel(), param);
        }

        ReportViewerModel GetSSRSModel()
        {
            string projectId = "1"; //ViewData["ReportProjectId"].ToString();
 
            ReportViewerModel reportModel = new ReportViewerModel();
            reportModel.ReportPath = Request.PhysicalApplicationPath + "ReportViewer\\Project Schedule Report.rdlc";
            //reportModel.ReportPath = Server.MapPath("~/ReportViewer/Project Schedule Report.rdlc");
            reportModel.EnableVirtualEvaluation = false;

            ReportDataSourceCollection dataSources = new ReportDataSourceCollection();

                //create an sql connection using the default connection string
            SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Repository"].ConnectionString);
            SqlCommand cmd = new SqlCommand("", cn);
            SqlDataAdapter da = new SqlDataAdapter();

            //Create the Projects DS
            cmd.CommandText = "Select ProjectID, ProjectNumber + ' - ' + ProjectName as 'ProjectName' from Projects order by 2";
            da.SelectCommand = cmd;
            DataTable dsProjects = new DataTable("Projects");
            da.Fill(dsProjects);
            //this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Projects", dsProjects));
            dataSources.Add(new ReportDataSource("Projects", dsProjects));
           
            //END Projects DS

            //Create the GeneralInformation DS
            cmd.CommandText = @"Select P.ProjectNumber,
                           P.ProjectName,
                           u.FirstName + ' ' + u.LastName + ' ' + u.ContactNumber as 'ProjectManager',
                           c.CampusName,
                           p.ProjectDescription
                            from Projects p left join
                           Users u on p.projectmanagerid = u.userid left join
                           Campus c on p.campusid = c.campusid 
                            where P.ProjectID = @ProjectID";
            da.SelectCommand = cmd;
            DataTable dsGeneralInformation = new DataTable("GeneralInformation");
            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@ProjectID", projectId);
            da.Fill(dsGeneralInformation);
            //this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("GeneralInformation", dsGeneralInformation));
            dataSources.Add(new ReportDataSource("GeneralInformation", dsGeneralInformation));
            //END GeneralInformation DS      

            //Create the Schedule DS
            cmd.CommandText = @"SELECT [MilestoneName] as 'Milestone'
                                      ,[OriginalDate]
                                      ,[ProjectedDate]
                                      ,[ActualDate]
                                      ,'' as Comments
                                  FROM [dbo].[ProjectMilestone]
                                  Where ProjectID = @ProjectID and Flag = 1
                                union  all
                                  SELECT [OtherDateName] as 'Milestone'
                                      ,[OriginalDate]
                                      ,[ProjectedDate]
                                      ,[ActualDate]
                                      ,'' as Comments
                                  FROM [dbo].[ProjectOtherDates]
                                  Where ProjectID = @ProjectID and Flag = 1
                                  order by OriginalDate";
            da.SelectCommand = cmd;
            DataTable dsSchedule = new DataTable("Schedule");
            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@ProjectID", projectId);
            da.Fill(dsSchedule);
            //this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Schedule", dsSchedule));
            dataSources.Add(new ReportDataSource("Schedule", dsSchedule));
            //END Schedule DS

            reportModel.DataSources = dataSources;

            return reportModel;
        }


View Code
<script type="text/javascript">
    var myVar;
    $(document).ready(function () {
        var online = window.navigator.onLine;
        if (!online) {
            StartTimer();
        }
    });

    function StartTimer() {
        myVar = setTimeout(function () {
            alert('Please check your internet connection and try again.');
            StopTimer();
        }, 7000);
    }

    function StopTimer() {
        clearTimeout(myVar);
    }
 </script>
...
     @{Html.Syncfusion().ReportViewer("Reports", (ReportViewerModel)ViewData["ReportModel"]).RequestMap("/Reports/SSRS").Render();}

      @{Html.Syncfusion().ScriptManager().Combine(true).Minify(true).Render();}

Soundara Rajan S [Syncfusion]
Replied On February 3, 2014 02:02 AM

Hi Brain,

 

Thanks for using Syncfusion Products.

 

We have created an incident for this forum, please follow the incident #118694  for more details.

 

Please let us know, if you have any queries.

 

Regards,

Soundara Rajan S

 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;