当前位置:编程学习 > C#/ASP.NET >>

reportview 再次绑定问题高手指教

button1里:
rvyear.LocalReport.DataSources.Clear();
                    rvyear.LocalReport.ReportPath = @"App_Code/Src/ReportView/Report1.rdlc";
                    rvyear.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
                    rvyear.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("MSSdata_Mssdata", dt));
                    rvyear.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("MSdata_MStata", dt1));
                    rvyear.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("t_Title", dts));
                    rvyear.LocalReport.Refresh();
 button2里:
 rvyear.LocalReport.DataSources.Clear();
               
                rvyear.LocalReport.ReportPath = @"App_Code/Src/ReportView/Report.rdlc";
                rvyear.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
                rvyear.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("sd_Sdata", dt));
                rvyear.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("t_Title", dts));
                rvyear.LocalReport.Refresh();
               当按button1后按button2就是提示button1里的MSdata_MStata数据没实例化,反正第一次绑定后绑定另外一个就会有问题,望高手指教 --------------------编程问答-------------------- 沙发,帮忙顶 --------------------编程问答-------------------- 我用的Form形式的,可以再次绑定,
处理前面加个 " this.reportViewer1.Reset();"

msdn解释reportViewer.Reset为
调用 Reset 方易做图取消所有当前呈现,并将 ReportViewer 控件重置为其默认状态。
--------------------------------------------------------------------------我的代码如下:
         //button 1
        private void button1_Click(object sender, EventArgs e)
        {
            
            this.reportViewer1.Reset();
            this.reportViewer1.LocalReport.ReportEmbeddedResource = "RDLCT.RDLC.Customers.rdlc";
            this.reportViewer1.LocalReport.DataSources.Clear();
            DataTable dt = RainingHeart_Customers_Select_All();//我的取customers数据          this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DSCustomers", dt));
            this.reportViewer1.RefreshReport();


        }

    //button 2
     private void button2_Click(object sender, EventArgs e)
        
        {   
             this.reportViewer1.Reset();
             this.reportViewer1.LocalReport.ReportEmbeddedResource = "RDLCT.RDLC.Orders.rdlc";
            this.reportViewer1.LocalReport.DataSources.Clear();
            DataTable dt = RainingHeart_Orders_Select_All();//我的取order 数据
            this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DSOrders", dt));
            this.reportViewer1.RefreshReport();
        } --------------------编程问答-------------------- 学习中
补充:.NET技术 ,  图表区
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,