日期:2014-05-20  浏览次数:20851 次

rdlc 报表Refresh()不能刷新数据
protected void ShowReport(string strYear1,string strYear2,string strMonth)
  {
  this.ReportViewer1.Reset();
  ReportViewer1.Visible = true;
  ReportViewer1.LocalReport.DataSources.Clear(); 
  string LAST_YEAR = strYear1;
  string NOW_YEAR = strYear2;
  string MONTH = strMonth;
  string procedureName = "";
  procedureName = "Report12_Year"; 
  DBAdapter adapter = new DBAdapter();
  ArrayList parms = new ArrayList(3);
  parms.Add(new SqlParameter("@LAST_YEAR", SqlDbType.VarChar,4));
  parms.Add(new SqlParameter("@NOW_YEAR", SqlDbType.VarChar, 4));
  parms.Add(new SqlParameter("@MONTH", SqlDbType.VarChar,4));
  ((SqlParameter)parms[0]).Value = LAST_YEAR;
  ((SqlParameter)parms[1]).Value = NOW_YEAR;
  ((SqlParameter)parms[2]).Value = MONTH;
  DataTable dataTable = adapter.
  ExecuteQueryReturnDataTable(procedureName, parms, false);  
  ReportViewer1.LocalReport.ReportPath = "ArtyWebPage/Reports/Report12_Year.rdlc";
  ReportViewer1.LocalReport.DataSources.Clear();
  ReportViewer1.LocalReport.DataSources.
  Add(new ReportDataSource("DataSetAll_Report12_Year", dataTable));
  ReportViewer1.LocalReport.Refresh();

  }
  protected void btnSeach_Click(object sender, EventArgs e)
  {
  ShowReport(ddlNf1.SelectedValue,ddlNf2.SelectedValue,ddlYf.SelectedValue);
  }

------解决方案--------------------
C# code
protected void ShowReport(string strYear1, string strYear2, string strMonth)
{
    this.ReportViewer1.Reset();
    ReportViewer1.Visible = true;
    ReportViewer1.LocalReport.DataSources.Clear();
    string LAST_YEAR = strYear1;
    string NOW_YEAR = strYear2;
    string MONTH = strMonth;
    string procedureName = "";
    procedureName = "Report12_Year";
    DBAdapter adapter = new DBAdapter();
    ArrayList parms = new ArrayList(3);
    parms.Add(new SqlParameter("@LAST_YEAR", SqlDbType.VarChar, 4));
    parms.Add(new SqlParameter("@NOW_YEAR", SqlDbType.VarChar, 4));
    parms.Add(new SqlParameter("@MONTH", SqlDbType.VarChar, 4));
    ((SqlParameter)parms[0]).Value = LAST_YEAR;
    ((SqlParameter)parms[1]).Value = NOW_YEAR;
    ((SqlParameter)parms[2]).Value = MONTH;
    DataTable dataTable = adapter.
    ExecuteQueryReturnDataTable(procedureName, parms, false);
    ReportViewer1.LocalReport.ReportPath = "ArtyWebPage/Reports/Report12_Year.rdlc";
    ReportViewer1.LocalReport.DataSources.Clear();
    ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetAll_Report12_Year", dataTable));
    ReportViewer1.LocalReport.Refresh();

}