here my problem is whenever postback happens the reportdocument r gets null and report disappears so i need to store reportdcument value to session
and call on every postbacknow i want to remove this session i use dataset to get values
public partial class register : System.Web.UI.Page
{
Class1 obj = new Class1(); //i use class file to getvalues
string sql = "";
Label l1;
DataTable dt = new DataTable();
CrystalDecisions.CrystalReports.Engine.ReportDocument r = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
protected void Page_init(object sender, EventArgs e)
{
if (IsPostBack == false)
{
CrystalReportViewer1.ReportSource = null;
CrystalReportViewer1.DataBind();
Session["reportpatientregistration"] = null;
}
crystal();
}
public void crystal()
{
if (Session["reportpatientregistration"] != null)
{
r = (ReportDocument)Session["reportpatientregistration"];
CrystalReportViewer1.ReportSource = r;
}
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
sql = "select query from table -----";
dt = obj.GetRecord(sql); // here query executes and set the value to datatable dt
r.Load(MapPath("~/CrystalReports/register.rpt"));
r.SetDataSource(dt);
CrystalReportViewer1.ReportSource = r;
CrystalReportViewer1.DataBind();
Session["reportpatientregistration"] = r;
}
}
arunkmohan18
Member
30 Points
158 Posts
crystal report problem
Aug 18, 2012 02:06 PM|LINK
here my problem is whenever postback happens the reportdocument r gets null and report disappears so i need to store reportdcument value to session
and call on every postbacknow i want to remove this session i use dataset to get values
public partial class register : System.Web.UI.Page
{
Class1 obj = new Class1(); //i use class file to getvalues
string sql = "";
Label l1;
DataTable dt = new DataTable();
CrystalDecisions.CrystalReports.Engine.ReportDocument r = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
protected void Page_init(object sender, EventArgs e)
{
if (IsPostBack == false)
{
CrystalReportViewer1.ReportSource = null;
CrystalReportViewer1.DataBind();
Session["reportpatientregistration"] = null;
}
crystal();
}
public void crystal()
{
if (Session["reportpatientregistration"] != null)
{
r = (ReportDocument)Session["reportpatientregistration"];
CrystalReportViewer1.ReportSource = r;
}
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
sql = "select query from table -----";
dt = obj.GetRecord(sql); // here query executes and set the value to datatable dt
r.Load(MapPath("~/CrystalReports/register.rpt"));
r.SetDataSource(dt);
CrystalReportViewer1.ReportSource = r;
CrystalReportViewer1.DataBind();
Session["reportpatientregistration"] = r;
}
}
Ramesh Chand...
Star
12922 Points
2672 Posts
Re: crystal report problem
Aug 18, 2012 03:06 PM|LINK
So, finally what problem you are facing ?
arunkmohan18
Member
30 Points
158 Posts
Re: crystal report problem
Aug 18, 2012 03:16 PM|LINK
i want to remove this session and how to stop null report on postback
Ramesh Chand...
Star
12922 Points
2672 Posts
Re: crystal report problem
Aug 19, 2012 09:38 AM|LINK
if you want to show report even in postback, you have to use the session.
Ajay2707
Contributor
4421 Points
856 Posts
Re: crystal report problem
Aug 21, 2012 05:06 AM|LINK
Hi Arunkmohan,
As Harsh said, this is standarad process to follow while postback. Read this article with same problem.
http://dotnetslackers.com/Community/forums/crystalreportviewer-disappears-after-postback/p/964/7314.aspx
http://social.msdn.microsoft.com/Forums/en-US/vscrystalreports/thread/2c4dcc6c-d17b-40b2-bf1d-96ffde5bd333
http://www.dotnetspider.com/forum/163725-crystal-report-viewer-disappearing.aspx