How to set width for ReportViewer for MVC

try to write the below code in your Controller

using System.Web.UI.WebControls;

  ReportViewer reportViewer = new ReportViewer();
  reportViewer.ProcessingMode = ProcessingMode.Local;
  reportViewer.SizeToReportContent = true;
  reportViewer.Width = Unit.Percentage(100);
  reportViewer.Height = Unit.Percentage(100);

Note: i am using ReportViewerForMvc from nuget

I found that I need to attack the width/height issue in two fronts - I added a CSS to modify the iframe in ReportViewerWebForm.aspx when it's loaded.

iframe {
  /*for the report viewer*/
  border: none;
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
}

The rest would be the same as the accepted answer except I removed

reportViewer.SizeToReportContent = True

from my controller because it hides the scroll bar which I need for the wider reports I render in the same Report.cshtml which is

@using ReportViewerForMvc; @{ ViewBag.Title = " Report"; }

<h2>Simple Report </h2>

@Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer)

My Controller:

 > 

 public ActionResult ReportByType()
        {
            var data =SomeFunction.CreateDataTable(GetReportDataFromDB());

            ReportViewer reportViewer = new ReportViewer();
            reportViewer.ProcessingMode = ProcessingMode.Local;

            reportViewer.LocalReport.ReportPath = 
              Request.MapPath(Request.ApplicationPath) + 
                   @"Views\Reports\ReportByType.rdlc";
            reportViewer.LocalReport.DataSources.Add(new 
               ReportDataSource("DataSet1", data));
           // reportViewer.SizeToReportContent = true; ---hides the scrollbar which i need
            reportViewer.Width = Unit.Percentage(100);
            reportViewer.Height = Unit.Percentage(100);

            ViewBag.ReportViewer = reportViewer;
            return PartialView("Report");

        }


        enter code here