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.Clear();

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

#endregion

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});

References:

http://stackoverflow.com/questions/4949205/how-do-i-use-linq-as-datasource-for-a-microsoft-report
http://www.datadynamics.com/forums/128880/PrintPost.aspx
http://heathesh.com/category/LINQ.aspx

http://www.neodynamic.com/ND/FaqsTipsTricks.aspx?tabid=66&prodid=1&sid=66
http://www.neodynamic.com/demo-faq/barcode-net-sdk/how-to-create-local-reports-rdlc-featuring-barcode-images-in-net-windows-forms.aspx
http://www.google.com.ph/url?sa=t&rct=j&q=how+to+create+rdlc+in+.net+4%3F&source=web&cd=4&ved=0CDQQFjAD&url=http%3A%2F%2Fweblogs.asp.net%2Frajbk%2Farchive%2F2010%2F05%2F09%2Fcreating-an-asp-net-report-using-visual-studio-2010-part-1.aspx&ei=-0UNT6iBM8THmQW42cyhBg&usg=AFQjCNGriPTPgbxMTc4VHV4WWBDn_MeIUg&cad=rja
http://www.codeproject.com/KB/reporting-services/DynamicReports.aspx
http://www.barcoderesource.com/RDLCReportBarcode.shtml
http://www.codeproject.com/KB/reporting-services/RDLC_and_DataSet.aspx
http://www.eggheadcafe.com/community/asp-net/17/10378000/how-to-make-rdlc-report.aspx
http://weblogs.asp.net/rajbk/archive/2010/05/09/creating-an-asp-net-report-using-visual-studio-2010-part-1.aspx

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

Advertisements
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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s