如何将参数传递给Rdlc报告 [英] How Do I Passing Parameter To Rdlc Report

查看:71
本文介绍了如何将参数传递给Rdlc报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我试图将参数从组合框传递到我的rdlc报告,下面是我的代码:



  private   void  ReportData( string  schname)
{
DataSet4TableAdapters.NotStartedRegTableAdapter ta = new DataSet4TableAdapters.NotStartedRegTableAdapter();
DataSet4.NotStartedRegDataTable dt = new DataSet4.NotStartedRegDataTable();
ta.Fill(dt,schname);
ReportDataSource rds = new ReportDataSource();
rds.Name = DataSet4;
rds.Value = dt;
// Microsoft.Reporting.WinForms.ReportDataSource reportDataSource4 = new Microsoft.Reporting.WinForms.ReportDataSource(DataSet4 ,dt.AsEnumerable()。CopyToDataTable());
ReportParameter rp = new ReportParameter( schoolName,schname);

reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.ReportPath = Report4.rdlc;
reportViewer1.LocalReport.SetParameters( new ReportParameter [] {rp});
reportViewer1.LocalReport.DataSources.Add(rds);
reportViewer1.LocalReport.Refresh();
}





调用方法:

 ReportData(cboSchools.Text); 



它没有报告任何错误,但是没有加载报告,我有什么遗漏?

解决方案

我能够自己解决这个问题,我添加了reportViewer1.LocalReport.Refresh();在调用方法之后,它的工作原理!感谢


Hello everyone,

I am trying to pass parameter from a combo box to my rdlc report, below is my code:

private void ReportData( string schname)
  {
      DataSet4TableAdapters.NotStartedRegTableAdapter ta = new     DataSet4TableAdapters.NotStartedRegTableAdapter( );
      DataSet4.NotStartedRegDataTable dt = new DataSet4.NotStartedRegDataTable( );
      ta.Fill( dt, schname );
      ReportDataSource rds = new ReportDataSource( );
      rds.Name = "DataSet4";
      rds.Value = dt;
      //Microsoft.Reporting.WinForms.ReportDataSource reportDataSource4 = new Microsoft.Reporting.WinForms.ReportDataSource( "DataSet4", dt.AsEnumerable( ).CopyToDataTable( ) );
      ReportParameter rp = new ReportParameter( "schoolName", schname );

      reportViewer1.LocalReport.DataSources.Clear( );
      reportViewer1.LocalReport.ReportPath = "Report4.rdlc";
      reportViewer1.LocalReport.SetParameters( new ReportParameter[] { rp } );
      reportViewer1.LocalReport.DataSources.Add( rds );
      reportViewer1.LocalReport.Refresh( );
  }



The calling method:

ReportData(cboSchools.Text );


its not reporting any error, but the report is not loaded, is there anything i am missing?

解决方案

i was able to resolve this myself, i added reportViewer1.LocalReport.Refresh( ); after the calling method, and it works! Thanks


这篇关于如何将参数传递给Rdlc报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆