Here you will find the steps:

Step 1

Below, you will find the table used in the application.



After creating the table, you can fill it using, for example, the data rows as shown below:



Step 2


Open Visual Studio, and Add New Project.





Step 3

Add Report file (.rdlc).

Now, you need to add a report file (.rdlc). Right click on project name and then Add> Add New Item > Reporting > Report > Add.



In this part, we need to configure our Report View with the fields which you want to add in the report. In this case, I chose to add all fields of my table.



Step 4

Configuring Dataset.

Here, we need to repeat the following steps for getting the same result.











After finishing the steps shown below, we will pass to the next step.

Step 5

Add Entity Data Model.

Right click on project name from solution explorer, then Add > New Item > Select ADO.Net Entity Data Model > Add.









Step 6

Add a View with .Aspx extension into the shared Folder.

Right Click on shared folder > Add > New Item >View Page (ASPX).

Step 7

You will add Report Viewer and Script Manager Controls from ToolBoxpanel as shown below.



Now, write the code between the head tag as follow.

  1. <headrunat="server">
  2. <metaname="viewport"content="width=device-width"/>
  3. <title> Data Report With MVC 4</title>
  4. <scriptrunat="server">
  5. void Page_Load(object sender, EventArgs e)
  6. {
  7. if (!IsPostBack)
  8. {
  9. List<ReportViewerMVC.Customers> customers = null;
  10. using (ReportViewerMVC.EntityFrameworkTestEntities _entities = new ReportViewerMVC.EntityFrameworkTestEntities())
  11. {
  12. customers = _entities.Customers.ToList();
  13. ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report/MyReport.rdlc");
  14. ReportDataSource RDS = newReportDataSource("DataSet1", customers);
  15. ReportViewer1.LocalReport.DataSources.Add(RDS);
  16. ReportViewer1.LocalReport.Refresh();
  17. }
  18. }
  19. }
  20. </script>
  21. </head>
Step 8

Add New Controller.

Right click on the Controllers folder > Add > Controller > Enter Controller name (“Customers”) > Add. By default we have index action as follows.
  1. publicclassCustomersController: Controller
  2. {
  3. //
  4. // GET: /Customers/
  5. publicActionResult Index()
  6. {
  7. return View();
  8. }
  9. }
Step 9

Add view related to Index Action.

At this level, we need to click on form action > Add View > Enter View name (Index)> Add.

Index.cshtml
  1. @{
  2. ViewBag.Title = "Display Data in the Report Viewer";
  3. }
  4. <h2>Display Data in the Report Viewer</h2>
  5. @* Here we call the page that I have been created into shared folder *@
  6. @Html.Partial("DataReport")
Step 10

Run Application.