You can attach a crystal report at the run time to a report viewer.
To attach a report to the report viewer at the run time follow the following steps:
Create the object of report document :
ReportDocument rpt=new ReportDocument();
Load the report it is assumed that the report reside of the root of the application:
rpt.Load(HttpContext.Current.Server.MapPath("abc.rpt"));
Set the data source of the report document :
rpt.SetDataSource(ds.Tables[0]);
Provide the value of the prameter if report contain any parameter
rpt.SetParameterValue("pName", "abc");
Set the report source of the report viewer to the report source.
To attach a report to the report viewer at the run time follow the following steps:
Create the object of report document :
ReportDocument rpt=new ReportDocument();
Load the report it is assumed that the report reside of the root of the application:
rpt.Load(HttpContext.Current.Server.MapPath("abc.rpt"));
Set the data source of the report document :
rpt.SetDataSource(ds.Tables[0]);
Provide the value of the prameter if report contain any parameter
rpt.SetParameterValue("pName", "abc");
Set the report source of the report viewer to the report source.