1. 程式人生 > >C#報表鑽取子報表

C#報表鑽取子報表

   private void Form1_Load(object sender, EventArgs e)
        {
            string sql = "select * from room";
            DataTable dt = dbutil.GetData(sql);
            ReportDataSource rds = new ReportDataSource("DataSet1", dt);
            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(rds);
            this.reportViewer1.LocalReport.Refresh();
            this.reportViewer1.RefreshReport();
        }

        private void reportViewer1_Drillthrough(object sender, Microsoft.Reporting.WinForms.DrillthroughEventArgs e)
        {
            LocalReport lr = (LocalReport)e.Report;

            lr.DataSources.Clear();

            string typeid = lr.GetParameters()[0].Values[0].ToString();

            string sql = "select * from roomtype where ids = " + typeid;

            DataTable dt = dbutil.GetData(sql);

            lr.DataSources.Add(new ReportDataSource("DataSet1", dt));
            lr.Refresh();


        }