How to create reports (rdlc) and load inside report viewer?

This blog will show you how to create report (rdlc not rdl) and display inside report viewer not thru browser. This post also shows you on how to use entity framework as a data source.

Step 1 – Find and Choose Report Wizard. You need to type your chosen report name.

Step 2 – Type in your chosen dataset name at dataset properties. Then click on Add button.

Step 3 – Either choose existing data source or create new data source. If you choose existing data source and select item from the drop down list. If you choose to create new connection, you need to click the button beside the drop down list.

Step 4 – Use the drop down list to select available dataset.

Step 5 – At Arrange fields, drop and drop items from Available fields to Values section.

Step 6 – Once you finish drag and drop, click next.

Step 7 – Click next.

Step 8 – Choose a style from the list. Click next.

Step 9 – Report Data will be display all fields selected.

Step 10 – The report will be displayed.

Step 11 – Right click on report viewer properties and set local report’s report path and data sources.

This is sample code, wherein you set data source and parameters of your report.

string Param1 = this.ddl_Param1.SelectedValue== “0” ? string.Empty : this.ddl_Param1.SelectedValue;

string Param2 = this.ddl_Param2.SelectedValue == “0” ? string.Empty : this.ddl_Param2.SelectedValue;

string Param3 = this.ddl_Param3.SelectedValue == “0” ? string.Empty : this.ddl_Param3.SelectedValue;

string Param4 = this.ddl_PARAM4.SelectedValue == “0” ? string.Empty : this.ddl_PARAM4.SelectedValue;

#region “ReportDataSource”

if (_myClassLibrary == null)

_myClassLibrary = new MyClassLibrary();

var list = new List<Entity>();

list = _myClassLibrary.myMethod(Param1, Param2, Param3, Param4);


this.Reportviewer.LocalReport.DataSources.Add(new ReportDataSource(“DataSet1”, list));


var Param1Param = new ReportParameter(“Param1”, Param1);

var Param2Param = new ReportParameter(“Param2Id”, Param2);

var Param3Param = new ReportParameter(“Param3Code”, Param3);

var Param4Param = new ReportParameter(“Param4Id”, Param4);

this.Reportviewer.LocalReport.SetParameters(new[] {Param2Param});

this.Reportviewer.LocalReport.SetParameters(new[] {Param3Param});

this.Reportviewer.LocalReport.SetParameters(new[] {Param1Param});

this.Reportviewer.LocalReport.SetParameters(new[] {Param4Param});


Note: I have not put any images yet and will later edit this post if I do have time to edit this post again.

This entry was posted in .NET Framework 4, C# 4.0 AND ASP.NET 4.0, Linq to Entity, RDLC, Report Viewer, Reporting Services 2008. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s