This is a migrated thread and some comments may be shown as answers.

set adapter at run time

1 Answer 138 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
nali
Top achievements
Rank 1
nali asked on 19 Jan 2007, 11:09 AM
I need to set the Select SQL at run time. I do it like this.

if (!IsPostBack)
{
MyReportLibrary.
testReport myReport = new testReport();
myReport.setAdapter(myAdapter);
this.reportViewer.Report = myReport;
}

But the problem is, that by the page loading, the constructor of testReport (where other connectionstring and Select_SQL are defined) will be called the second time and the properties of
myReport.setAdapter(myAdapter)
will be lost.

Who calls (creates) the myReport again?
I suppose , that it is the reportViewer. The Viewer re-create the class myReport (actually testReport) and so myAdapter will be lost.

How can I set the Adapter outside of the Report ? 

1 Answer, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 23 Jan 2007, 02:01 PM
Hello Uladzimir,

In the current release of the Reporting (CTP2), there is an issue with the ReportViewer's implementation and it recreates the report after it has been already created. This problem, luckily, has been already fixed and will appear in the upcoming beta next month.

As a suggestion for a workaround I would recommend you to set the DataSource property of the report in the report's constructor if possible. For example:

         public testReport()
         {                       
              InitializeComponent();
              this.DataSource = myAdapter;                      
         }

All the best,
Chavdar
the telerik team
Tags
General Discussions
Asked by
nali
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Share this question
or