locked
crystal report does not work properly RRS feed

  • Question

  • User1784660007 posted

    hi

    i am working on crystal report 

    in which i have more data for that i want to go on next page but when i click on next then in gives me erro:

    No valid report source is available.

    MyCode Is:

    protected void Button1_Click(object sender, EventArgs e)
    {
    GetData();
    }


    private void GetData()
    {
    SqlConnection connection = new SqlConnection(strcon );
    SqlCommand command = new SqlCommand("Select * from demoforreport WHERE role='" + TextBox1 .Text +"'", connection);
    SqlDataAdapter adapter = new SqlDataAdapter(command);
    //Customer _Customer = new Customer();
    DataSet dataset = new DataSet();
    adapter.Fill(dataset, "demoforreport");
    ReportDocument CustomerReport = new ReportDocument();
    CustomerReport.Load(Server.MapPath("CrystalReport.rpt"));
    CustomerReport.SetDataSource(dataset.Tables["demoforreport"]);
    CrystalReportViewer1.ReportSource = CustomerReport;
    CrystalReportViewer1.DataBind();

    }

    help me 

    thanks


    Tuesday, August 13, 2013 3:53 AM

All replies

  • User-849598927 posted

    Use this in page_load event

    if (IsPostBack)
    {
    if (Session["reportDocument"] != null)
    {
    ReportDocument cr = new ReportDocument();
    cr = (ReportDocument)Session["reportDocument"];
    CrystalReportViewer1.ReportSource = cr;
    CrystalReportViewer1.DataBind();
    }
    }

    Wednesday, October 9, 2013 5:43 AM
  • User-37275327 posted

    CR needs to rebind the report when Next button click.

    Page_Load()
    {
          GetData();
    }

    Do not check IsPostBack property.

    Friday, October 11, 2013 4:16 AM