2 Replies Latest reply: May 5, 2014 8:01 AM by M K RSS

No valid report source is available  error + crystal report on navigation

Simon mwai
Currently Being Moderated

Hi all,

am using c#,asp.net and crystal report for report.

have loaded data on a dataset and on clicking a button the page loads okay when i click on next button to navigate to next page of the report am getting the following error message   *No valid report source is available"

this is my code

try

        {

            connection.Open();

            da.Fill(ds, "Statement");

            ds.Tables[0].TableName = "Statement";

            

                //RateeReport = new RateeReport();

                ReportDocument myReportDocument;

                myReportDocument = new ReportDocument();

                myReportDocument.Load(Server.MapPath("~/Reports/Statementreport.rpt"));

                myReportDocument.SetDataSource(ds);

                Session["Report"] = myReportDocument;

                if (!IsPostBack)

                {

                     

 

                    CrystalReportViewer1.ReportSource = myReportDocument;

                    CrystalReportViewer1.DataBind();

                }

                else

                {

                    CrystalReportViewer1.ReportSource = Session["Report"];

                    CrystalReportViewer1.DataBind();

                }

 

        }

please assist augently for me to navigate.

    • Re: No valid report source is available  error + crystal report on navigation
      Khalid Rafique
      Currently Being Moderated

      Store you report in Session and then give report sorce from session on page postback

       

      protected void Page_Load(object sender, EventArgs e)

          {

              if (IsPostBack)

              {

                  try

                  {

                      CrystalReportViewer1.ReportSource = (ReportDocument)Session["Report"];

                      CrystalReportViewer1.RefreshReport();

                      CrystalReportViewer1.DataBind();

                  }

                  catch (Exception ex)

                  {

                       

                     // throw;

                  }

              }

               

          }

          protected void CrystalReportViewer1_PreRender(object sender, EventArgs e)

          {

               

          }

          protected void btnPrint_Click(object sender, EventArgs e)

          {

              ReportDocument rptDoc = new ReportDocument();

              rptDoc.Load(Server.MapPath("Reports
      BalanceReportNew
      BalanceReport.rpt"));

              rptDoc.SetDataSource(ReportData());

              Session["Report"] = rptDoc;

              CrystalReportViewer1.ReportSource = rptDoc;

              CrystalReportViewer1.RefreshReport();

              CrystalReportViewer1.DataBind();

          }

          public DataTable ReportData()

          {

              string ClassName = ddlClass.SelectedValue;

              string Division = ddlDivison.SelectedValue;

              string Subject = ddlSubjects.SelectedValue;

              DataTable ReportData = objRpt.getReportData(ClassName, Division, Subject);

              return ReportData;

          }

Actions