Failed to export using the options you specified. Please check your options and try again.
因為按下匯出時,會postback,需要再做一次資料繫結.
protected void Button_Click(object sender, EventArgs e)
{
DataSet ds = LoadData();
ReportDocument Report2 = new ReportDocument();
string reportPath = Server.MapPath(@".\App_Data\CrystalReport2.rpt");
Report2.Load(reportPath);
Report2.SetDataSource(ds);
CrystalReportViewer1.ReportSource = Report2;
Session.Add("report", Report2);
}
protected void Page_Load(object sender, EventArgs e)
{
//處理Viewer匯出
if (Page.IsPostBack && Session["report"] != null)
{
CrystalReportViewer1.ReportSource = Session["report"];
}
}
參考
Report dissapear on postback
How to use "Print" and " Export" option from CrystalRep
沒有留言:
張貼留言