Friday 12 October 2012

Create RDLC Report in ASP.net



Insert RDLC page in your Project.
Then Design Your RDLC (report) page. With the help of text box and Table

Create Parameter


Click the report Data in your RDLC page
Then Right Click On the parameter and click add

Assign Parameter Value to Textbox

Right Click RDLC page textbox Then Click Expression
Click Parameter Then Double Click Your Parameter Name

Pass Parameter value from code behind


Add  Microsoft.ReportViewer.Common Dll and Microsoft.ReportViewer.WebForms
Dll To Your Project.
Then add using Microsoft.Reporting.WebForms;
Namespace in your coading page.

ArrayList list = m_alStudPaymentDetail[dtIndex] as ArrayList;
hnCurrentPayment.Value = (string)list[0];

rptViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("", dtPayRpt.DefaultView));
ReportParameter[] param = new ReportParameter[8];
param[0] = new ReportParameter("param0", “printBy”);
param[1] = new ReportParameter("param1", "Printed Date  :" + date[0].ToString());
param[2] = new ReportParameter("param2", "StudentName");
param[3] = new ReportParameter("param3", "CourseName");
param[4] = new ReportParameter("param4", "FeeDetail");
param[5] = new ReportParameter("param5", "Date");
param[6] = new ReportParameter("param6", "TotalFee");
param[7] = new ReportParameter("param7", "Father Name")        rptViewer.LocalReport.SetParameters(param);
rptViewer.LocalReport.Refresh();



Set RDLC page Table Value in ASP.net


Create a new XSD page in your Project
Right Click on This Page
Then click Add à DataTable




Add Your column in that the Data Table




Then Set DataTable Name to Table DataSourse

Pass DataTable Value To RDLC Report

DataTable dtProject = BLL.ReportQuery.clsAmountPayReceive.GetSalesItem();

rptViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
rptViewer.LocalReport.ReportEmbeddedResource       "WebUI.Forms.ShrooqalReport.DetailsOfSales.rdlc";
rptViewer.LocalReport.DataSources.Clear();

rptViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("Rdlc DataTableName", dtProject.DefaultView));
rptViewer.LocalReport.Refresh();


Then Run the Project and see The Report .

Thank You

No comments:

Post a Comment