Thursday, September 15, 2011

CrystalReport Problem solving.

Calling Report Page From Main Screen :

ScriptManager.RegisterStartupScript(this, typeof(string), "Showing Modalpopup", "window.open('Report.aspx?ReportName=Test',  'Report', 'width=800,height=400,resizable=yes,status=yes,scrollbars=yes');", true);

Crystal Report Binding Code :

using CrystalDecisions.CrystalReports;
using CrystalDecisions.Web;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data;

               //Write the Below lines of code in Page_Load Event.
              
                ReportDocument rpt = new ReportDocument();
                string strPath = null;
                DataSet ds = new DataSet();
                ds = (DataSet)Session["ReportData"];
                //get the strReportName from querystring.
                strPath = Server.MapPath(@"~\ModuleName\ReportsFolderPath\" + strReportName + ".rpt");
                rpt.Load(strPath);
                rpt.SetDataSource(ds);
                crvReports.ReportSource = rpt;
                crvReports.RefreshReport();
                crvReports.DisplayGroupTree = false;
                crvReports.DataBind();