I have multiple Crystal Reports in checkboxlist, so that user can print/show multiple reports at same time.
Currently I am using session to pass the reportdocument, but most of the time the session value get replace before assigning to crystal report, as a result multiple reports contain same data. I have applied 3 sec delay on each loop but not reliable solution. And Also Image are not displaying in Reports.
Is there any elegant technique to do this??
Or
What will be alternative for Session variable?
Jquery:
$.each(chkBoxarr, function (index, value) {
var w = window.open();
$.ajax({
type: "POST",
url: "PrintReports",
traditional: true,
data: { id: value},
datatype: "json",
success: function (data) {
w.document.write(data);
},
error: function () {
alert("Error");
}
});
});
Controller:
public ActionResult PrintReports(id)
{
ReportDocument rpt = new ReportDocument();
rpt.Load("~/ReportFileName.rpt");
HttpContext.Session["rpt"] = rpt;
return Redirect("~/Viewer.aspx");
}
Viewer.aspx.cs
Page_Init(object sender, EventArgs e)
{
var rpt = System.Web.HttpContext.Current.Session["rpt"];
CrystalReportViewer1.ReportSource = (ReportDocument)rpt;
}