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

为什么水晶报表 我无法使用 导出功能和打印这些功能呢,
代码如下
using System.Data.SqlClient;
using System.Data.Sql;
public partial class report_Default : System.Web.UI.Page
{
  string strsql = null;
  protected void Page_Load(object sender, EventArgs e)
  {
  if (!IsPostBack)
  {
  SearchData();
  }
  }
  protected void SearchData()
  {
  strsql = "SELECT REPORT_TABLE.SITE_NAME,";
  strsql = strsql + " SUM(REPORT_TABLE.PFNDJZ)/count(*) AS PFZL ";

   

  strsql = strsql + " FROM REPORT_TABLE";
  strsql = strsql + " group by REPORT_TABLE.SITE_NAME";
   
  using (SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MSSQL2000"].ConnectionString))
  {  
  SqlDataAdapter rs = null;  
  try
  {
  connection.Open();
  rs = new SqlDataAdapter(strsql, connection);
  DataSet1 ds1 = new DataSet1();
  rs.Fill(ds1, "REPORT_TABLE");
   
  //使用报表对象加载报表
  ReportDocument myReport = new ReportDocument();
  string reportPath = Server.MapPath("~/report/rpt/CrystalReportTest.rpt");
  myReport.Load(reportPath);


  //绑定数据集,注意,一个报表用一个数据集。
  myReport.SetDataSource(ds1);
  CrystalReportViewer1.ReportSource = myReport;
  CrystalReportViewer1.DataBind(); 

  }
  catch (System.Data.SqlClient.SqlException ex)
  {
  Response.Write(ex.Message);

  }
  finally
  {

   
  if (connection != null)
  {
  if (connection.State == ConnectionState.Open) connection.Close();
  connection.Dispose();
  }
  }
  }
  }
}


我只要是一点 水晶报表上的 导出 。打印等任何一个按纽 报表页面消失 ,然后点ie的后退 才能看到,该怎么解决 ,为什么

------解决方案--------------------
IsPostBack
去掉,你点那些按钮是要刷新页面的