How to Create Subreport using Microsoft Reporting Service
Introduction...
Introduction
I assumed that user have read this article
http://www.codeproject.com/KB/aspnet/ReportViewer_and_SSRS.aspx
Background
How to create and use sub reports using Microsoft Reports Here are the steps user can follow and create sub reports.
Step1:Create AddressInfo table and enter some data as show below.
Step2: Add New report to your project
Step3: Add a new DataTable to your dataSet Here is a sample of DataSet
Step4:Drag and drop a table on your report and
Step5:Drag and drop fields from your datasoure table to the report
Step6: User can delete the header and the footer since we are not using it this how the report will look
Step7: Add your Paramter to your report(Sub report)
Step8: Add you sub report to your main report
Step9: Link your report paramter from main to subreport using the property of the subreport.
Step 10: Here is the sample of the report.
The Code
ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(MySubreportProcessingEventHandler); MyDataClassesDataContext db = new MyDataClassesDataContext(); IQueryable<StudentInfo> data = from d in db.StudentInfos select d; ReportDataSource rds = new ReportDataSource("MyDataSet_StudentInfoDataTable", data); ReportViewer1.LocalReport.DataSources.Add(rds); } private void MySubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e) { MyDataClassesDataContext db = new MyDataClassesDataContext(); IQueryable<AddressInfo> mdata = from d in db.AddressInfos where d.StudentId.Equals(e.Parameters[0].Values[0].ToString()) select d; e.DataSources.Add(new ReportDataSource("MyDataSet_AddressDataTable", mdata)); }