locked
Crystal report viewer toolbar not working in asp.net c# RRS feed

  • Question

  • User-1078128378 posted

    Hi All,

    I am using sap crystal reports in visual studio 2010

    report is loading properly.

    when i click any thing on toolbar(zoom,search,page navigation,export) it says no valid report source is available

    error.PNG (476×175)

    I am using following code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    using System.Data;
    
    public partial class Reports_ClassWise : System.Web.UI.Page
    {
        ReportDocument reportdocument;
        protected void Page_Init(object sender, EventArgs e)
        {
            if (reportdocument == null)
            {
                reportdocument = new ReportDocument();
            }
            if (!Page.IsPostBack)
            {            
                loadClasses();
                ddlClass.Focus();
                
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        { 
        }
        protected void Page_Unload(object sender, EventArgs e)
        {
            if (reportdocument != null)
            {
                reportdocument.Close();
                reportdocument.Dispose();
            }
        }
      
        private void SearchStudent()
        {
            
            ParameterField paramField = new ParameterField();
            ParameterField paramField1 = new ParameterField();
            ParameterFields paramFields = new ParameterFields();
            ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
            ParameterDiscreteValue paramDiscreteValue1 = new ParameterDiscreteValue();
    
    
            paramField.Name = "@classid";
            paramDiscreteValue.Value = Convert.ToInt64(ddlClass.SelectedValue.ToString());
    
            paramField.CurrentValues.Add(paramDiscreteValue);
            paramFields.Add(paramField);
    
            paramField1.Name = "@ClassName";        
            paramDiscreteValue1.Value = ddlClass.SelectedItem.Text;
    
            paramField1.CurrentValues.Add(paramDiscreteValue1);
            paramFields.Add(paramField1);
    
            CrystalReportViewer1.ParameterFieldInfo = paramFields;
            reportdocument.Load(Server.MapPath("~/CrystalReports/Student/ClassWise.rpt"));
            reportdocument.FileName = Server.MapPath("~/CrystalReports/Student/ClassWise.rpt");
            reportdocument.SetDatabaseLogon(Global.User, Global.Pwd, Global.Server, Global.Db);
            CrystalReportViewer1.ReportSource = reportdocument;
    
        }
        private void loadClasses()
        {
            ClassBAL ob = new ClassBAL();
            DataTable dt = ob.getAllClasses();
            ddlClass.DataSource = dt;
            ddlClass.DataTextField = "ClassName";
            ddlClass.DataValueField = "ClassId";
            ddlClass.DataBind();
            ddlClass.Items.Insert(0, new ListItem("All", "0"));
    
        }
        protected void LbSearch_Click(object sender, EventArgs e)
        {
            SearchStudent();
            ddlClass.Focus();
        }
    }

    how can i use toolbar options?

    Thanks,

    Wednesday, August 12, 2015 1:42 AM

All replies

  • User-219423983 posted

    Hi Murali,

    First of all, you could step by step to debug the code when you use the toolbar. As you said the report is loading properly, you could refer to the following article to check whether you load the data to report correctly when happen postback.

    http://www.aspsnippets.com/Articles/ASPNet-Crystal-Reports-13-Visual-Studio-2010-CrystalReportViewer-Search-Button-Issue---No-valid-report-source-is-available.aspx

    I hope it’s useful to you.

    Best Regards,

    Weibo Zhang

    Wednesday, August 12, 2015 7:18 AM
  • User-1078128378 posted

    Hi Weibo zhang,

    Thanks for the reply

    now toolbar is working

    but when i click search button again

    report not loading simply it return just error keyword only.

    Friday, August 14, 2015 2:15 AM
  • User-219423983 posted

    Hi Murali,

    You could first to debug your code step by step to find out the issue point and then check whether the official website has the solution about this error keyword. Or could you provide some error details?

    I hope it’s useful to you.

    Best Regards,

    Weibo Zhang

    Sunday, August 16, 2015 11:19 AM