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

Dynamic Datasource

1 Answer 362 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 14 Mar 2012, 06:06 PM
Hello.  I set up a few Telerik reports a couple of years ago, and now I'm trying to remind myself how they work.  :-)

I am creating a new report that has a dynamic datasource here:
public Report1()
    {
        /// <summary>
        /// Required for telerik Reporting designer support
        /// </summary>
        InitializeComponent();
 
        //
        // TODO: Add any constructor code after InitializeComponent call
        //
 
 
        this.NeedDataSource += new System.EventHandler(this.Report1_NeedDataSource);
    }
 
    private void Report1_NeedDataSource(object sender, EventArgs e)
    {
        Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
 
        int advertiserID = int.Parse(report.Parameters["advertiserID"].Value.ToString());
        DateTime dtStartDate = DateTime.Parse(report.Parameters["startDate"].Value.ToString());
        DateTime dtEndDate = DateTime.Parse(report.Parameters["endDate"].Value.ToString());
 
        report.DataSource = (GetBannersByMonthByAdvertiser(advertiserID, dtStartDate, dtEndDate)).Tables[0];
    }


The report works fine when I build the project and view it through the report viewer, however, I cannot get the data to run in the Preview version of the report, and the designer does not recognize that any fields are available for the report.

I tried using a SqlDataSource stored procedure, but I have been unable to successfully pass in the date parameters when trying to run the stored procedure. 

So, my question is:  how to I get the report to recognize that data fields are available for creating the report when I have a dynamic data source?  Thanks!!

1 Answer, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 15 Mar 2012, 06:17 PM
Hi Angie,

The only way to have design-time support is to initialize the DataSource components with the designer (not in the code-behind). The piece of code that you have provided can easily be replaced with an objectDataSource component with 3 parameters, providing you design-time support. 

All the best,
Elian
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
Tags
General Discussions
Asked by
Angie
Top achievements
Rank 1
Answers by
Elian
Telerik team
Share this question
or