Click here to Skip to main content
15,887,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I want to display a RDLC report in my view (.cshtml).

I have Data model with data. So i want to display them on report.

//-------------------------------
Controller action
------------------------------------
C#
public ActionResult ViewRemmitReportList(int period, string fromDate, string toDate)
        {
            var creditorId = Crypto.Decrypt(Convert.ToString(Session["CreditorId"]));
            USCPIService uscpService = new USCPService();
            var finalRemitDto = uscpService.GetFinalRemmitDtoResult(creditorId, period.ToString(), fromDate, toDate);
            ReportViewer reportViewer = LoadRemmitReport(finalRemitDto,fromDate, toDate);
            ViewBag.ReportViewer = reportViewer;
            return PartialView("_RemmitReportResult");
        }


After that view file as following,
------------------------------------------
@using ReportViewerForMvc
@model US.BOX.CreditorPortal.Web.Model.ReportResultModel

C#
<div id="reportView" class="table-responsive">
    <iframe width="100%" height="300px" name="iframe_a">       
        @Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer, new {scrolling = "yes", width = "100%"})        
    </iframe>
</div>


So that's it. But I will display only Iframe. no details.
Please help me to display them on view.
I have tried more than 2 days.
Thanks all.
Posted

1 solution

That's not how the <iframe> tag[^] works. You can't just render content within the tag - you have to either set the src attribute to the address of the document you want to display, or set the srcdoc attribute to the HTML of the document you want to display.

Assuming you're using this library[^], you don't need the <iframe> tag at all. The ReportViewer method will take care of that for you:
HTML
<div id="reportView" class="table-responsive">
    @Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer, new {scrolling = "yes", width = "100%"})        
</div>
 
Share this answer
 
Comments
Member 11670657 27-Jan-16 9:16am    
Thanks. Great friend. you are correct.
jigneshNP 19-Mar-19 9:18am    
Hello Guy's,

I am looking for creating .rdlc file dynamically, Means I want to display report in report viewer control from direct datasource/list in MVC 2 using C#.(Without creating .rdlc file and .xsd dataset files). Is there anyway then please help me.

Thanks in Advance

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900