Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a Project in ASP.NET using C# as Back End.
In my project i have use crystal report to show reports to user.

I have dynamic report like when user select 1 report then the Crystal Report Viewer Show the First Report or it select second then the crystal report viewer show the second report.
and i have also pass the parameter value to my report by seting crystal report viewers paramterfiledinfo property.

now i have done it and it will work great. but my problem is arise when i have more then one page data in report and i went to second page it will show error like this..

"No valid report source is available"

please help me...
Posted
Comments
Artashes Tovmasyan 23-Jun-16 3:20am    
Hi :) I'm having the same problem
Did you solve the paging problem ??

Thanks in advance
Tejas Vaishnav 29-Jun-16 1:34am    
Can you check answers listed below, may solve your problem.

I think you need to bind the data to the report every time the Report viewer page postback, as following:

C#
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt;

protected void Page_Load(object sender, EventArgs e)
    {
        rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            rpt.Load(Server.MapPath(GetFilePath(/*report file path*/)));
            if (rptData is DataSet)
                rpt.SetDataSource((DataSet)rptData);
            else if (rptData is DataTable)
                rpt.SetDataSource((DataTable)rptData);
            else if (rptData is IEnumerable)
                rpt.SetDataSource((IEnumerable)rptData);

            CrystalReportViewer1.ReportSource = rpt;
            CrystalReportViewer1.DataBind();
    }


and close the report every time the page unload, as following:

C#
protected void Page_UnLoad(object sender, EventArgs e)
    {
        if (rpt != null)
        {
            rpt.Close();
            rpt.Dispose();
        }
    }
 
Share this answer
 
Comments
cutest 17-Apr-16 4:38am    
crystal report is useless
Fro solving this issue i need to do like this....

after assinig a report to report viwer i will add it to session also displaying report and also call this function in side OnNavigate or OnViewZoom etc.... events of report viewer

C#
protected void setReportSource(object sender, EventArgs e)
{
   if (Session["Report"] != null)
   {
       if (Session["Parameter"] != null)
       {
            CRPTViewer.ParameterFieldInfo = (ParameterFields)Session["Parameter"];
       }
       CRPTViewer.ReportSource = (ReportDocument)Session["Report"];
   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900