Click here to Skip to main content
13,096,798 members (94,793 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
private void Form1_Load(object sender, EventArgs e)
        {
            LoadReport();
            //  this.ReportViewer1.RefreshReport();
            // this.ReportViewer1.RefreshReport();
        }
        private void LoadReport()
        {
            try
            {
 
                GetData();
                ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
                LocalReport localReport = ReportViewer1.LocalReport;
                // localReport.ReportEmbeddedResource = @"D:\Arvind\Projects\RDLC Report Practice\RDLC Report Practice\Report1.rdlc";
                localReport.ReportPath = @"D:\Arvind\Projects\RDLC Report Practice\RDLC Report Practice\Report1.rdlc"; //Server.MapPath("Reports/Report2.rdlc");
                //ReportViewer1.ProcessingMode = ProcessingMode.Local;
                this.ReportViewer1.Width = 400;
                this.ReportViewer1.Height = 300;
                ReportDataSource rds = new ReportDataSource();
                rds.Name = "Report1";
                rds.Value = dt;
                localReport.DataSources.Add(rds);
                //ReportViewer1.DataBindings.Add("StudentName", dt, "StudentID");//.LocalReport.repo.LocalReport.DataSources.Add(rds);
                //ReportViewer1.LocalReport.DataSources.Add(rds);
                // ReportViewer1.DataBindings.Add("Text", dt, "StudentID");
                ReportViewer1.RefreshReport();//.LocalReport.Refresh();
                localReport.DataSources.Clear();
                // ReportViewer1.Visible = true;
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
 
        private DataTable GetData()
        {
            dt.Columns.Add("StudentID");
            dt.Columns.Add("StudentName");
            DataRow dr = dt.NewRow();
            dr["StudentId"] = 100;
            dr["StudentName"] = "Santhosh";
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr["StudentId"] = 101;
            dr["StudentName"] = "Kumar";
            dt.Rows.Add(dr);
            return dt;
        }
Posted 13-Nov-12 23:28pm
Updated 13-Nov-12 23:41pm
digimanus60.6K
v2
Comments

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100