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.
Syncfusion Feedback

Data not binding to Report viewer using ASP.NET MVC

Thread ID:

Created:

Updated:

Platform:

Replies:

121537 Dec 28,2015 05:48 AM UTC Dec 30,2015 05:06 AM UTC ASP.NET MVC 3
loading
Tags: ReportViewer
dhanashri kadam
Asked On December 28, 2015 05:48 AM UTC

I have used syncfusion report viewer but while loading report in view there is Excepition thrown

the screen snapshot or exception i attached with thread


the view code is:

<link rel='nofollow' href="http://cdn.syncfusion.com/js/web/flat-azure/ej.web.all-latest.min.css" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js" type="text/javascript"></script>
<script src="http://cdn.syncfusion.com/js/web/ej.web.all-latest.min.js" type="text/javascript"></script>
<script src=" http://cdn.syncfusion.com/js/web/ej.unobtrusive-latest.min.js" type="text/javascript"></script>

@using Syncfusion.MVC.EJ
@using Syncfusion.JavaScript.Models
@using Syncfusion.JavaScript
@*@using Syncfusion.JavaScript.ReportViewer*@

  <div style="width: 100%">
      @(Html.EJ().ReportViewer("viewer").ProcessingMode(Syncfusion.JavaScript.ReportViewerEnums.ProcessingMode.Local)
.ReportPath("Customer.rdlc")
.ReportServiceUrl("api/ReportApi")
.DataSources(ds => ds.Name("Customer").Value(ViewData["cust"]).Add()))

  </div>


and the code of controlle as :
   public class ReportApiController : Controller, IReportController
    {
        public ActionResult Report()
        {
            ViewData["cust"] = GetList();
            return View();
        }
        public object PostReportAction(Dictionary<string, object> jsonResult)
        {
            return ReportHelper.ProcessReport(jsonResult, this);
        }
        //Get action for getting resources from the report
        [System.Web.Http.ActionName("GetResource")]
        [AcceptVerbs("GET")]
        public object GetResource(string key, string resourcetype, bool isPrint)
        {
            return ReportHelper.GetResource(key, resourcetype, isPrint);
        }
        //Method will be called when initialize the report options before start processing the report
        public void OnInitReportOptions(ReportViewerOptions reportOption)
        {
            //You can update report options here
        }
        //Method will be called when reported is loaded
        public void OnReportLoaded(ReportViewerOptions reportOption)
        {
            //You can update report options here
        }

        [HttpPost]
        public List<CustomerVM> GetDataForReport()
        {
            return GetList();
        }

        private List<CustomerVM> GetList()
        {
            var list = new List<CustomerVM>();

            var cust1 = new CustomerVM { Id = 1, FirstName = "ssss", LastName = "ff", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust2 = new CustomerVM { Id = 2, FirstName = "ddd", LastName = "bbb", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust3 = new CustomerVM { Id = 3, FirstName = "ccc", LastName = "mmm", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust4 = new CustomerVM { Id = 4, FirstName = "ssss", LastName = "ff", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust5 = new CustomerVM { Id = 5, FirstName = "ddd", LastName = "bbb", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust6 = new CustomerVM { Id = 6, FirstName = "ccc", LastName = "mmm", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust7 = new CustomerVM { Id = 7, FirstName = "ssss", LastName = "ff", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust8 = new CustomerVM { Id = 8, FirstName = "ddd", LastName = "bbb", MobileNo = "9098908990", Email = "a@gmail.com" };
            var cust9 = new CustomerVM { Id = 9, FirstName = "ccc", LastName = "mmm", MobileNo = "9098908990", Email = "a@gmail.com" };

            list.Add(cust1);
            list.Add(cust2);
            list.Add(cust3);

            list.Add(cust4);
            list.Add(cust5);
            list.Add(cust6);

            list.Add(cust7);
            list.Add(cust8);
            list.Add(cust9);

            return list;
        }

}


and i have set application startup page in Global.aspx.cs:

  public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Login", action = "Login", id = UrlParameter.Optional } // Parameter defaults
            );
          
        }


Attachment: Image1_2744d245.rar

Soundara Rajan S [Syncfusion]
Replied On December 29, 2015 06:26 AM UTC

Hi Dhanashri,

Thanks for contacting Syncfusion support.

In the shared code example, you have inherited the IReportController in MVC controller instead of WebAPI controller. We are internally processing the report based on WebAPI JSON results (RESTFUL Service) and it’s not working with MVC action result. Due to this, you have faced the mentioned issue at your end. So, please inherit the IReportController in your WebAPI instead of MVC controller.

We have prepared standalone based on your requirement and it can be downloaded from below location,
http://www.syncfusion.com/downloads/support/directtrac/142785/MVCReportSample1020409770.zip 
http://www.syncfusion.com/downloads/support/directtrac/148270/ze/ReportViewerMVC5868312663.zip


You can obtain the MVC ReportViewer samples from the below build installed location,
%userprofile%\AppData\Local\Syncfusion\EssentialStudio\$version$\MVC\Samples

Please refer to the below UG documentation for more details,
http://docs.syncfusion.com/aspnetmvc/reportviewer/getting-started

Regards,
Soundara Rajan S

dhanashri kadam
Replied On December 29, 2015 06:37 AM UTC

Thanks for your reply.

Soundara Rajan S [Syncfusion]
Replied On December 30, 2015 05:06 AM UTC

Hi Dhanashri,

Thanks for your response. Please let us know, if you need any further assistance on this.

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.

Warning Icon 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.Close Icon

;