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

NeedDataSource Event

4 Answers 562 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bryan Strader
Top achievements
Rank 2
Bryan Strader asked on 10 Sep 2009, 03:00 PM
In trying to work with stored procedures to generate data for a Telerik report, I followed the tutorial located at this link:

http://www.telerik.com/support/kb/reporting/general/using-data-source-with-parameters-in-telerik-reporting.aspx


I have no data source set for the report, and am setting the data source to null during the constructor of the report object.

The issue is that the NeedDataSource Event does not seem to be firing....Is there anything else that needs to be done for the report to make this event fire when there is no data source?

I have tried using NeedDataSource and Need_DataSource...but still cannot get the event to fire....? Any further information that the tutorial might not include would be very helpful....Thanks!


     public MyReport()
        {
            InitializeComponent();
            this.DataSource = null;
        }

 private void MyReport_NeedDataSource(object sender, System.EventArgs e)
        {
            this.sqlDataAdapter1.SelectCommand.Parameters[@"ID"].Value = this.ReportParameters["VolID"].Value;

            Telerik.Reporting.Processing.Report rptTestReport = (Telerik.Reporting.Processing.Report)sender;

            rptTestReport.DataSource = this.sqlDataAdapter1;
        }

4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 11 Sep 2009, 02:39 PM
Hi Bryan,

There is a single event which can be used for binding the report - NeedDataSource. In this line of thoughts, we are not sure of the Need_DataSource part you've mentioned. As explained in the article you've referenced, NeedDataSource event is raised only when the report has no data source set and we notice that you've already set  this.DataSource = null; in the report constructor. So the only possible explanation for the event not to fire, would be if it is not wired. Did you wire it from the report designer or copy/pasted it directly from the KB article? If the latter, the event is not wired and should be attached respectivelly i.e.:

this.NeedDataSource += new System.EventHandler(this.Report1_NeedDataSource);

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Bryan Strader
Top achievements
Rank 2
answered on 11 Sep 2009, 03:04 PM
Thank you, it turns out I was behind one version, after upgrading to 2009 Q2, The event was available, and after wiring it up, it's working perfectly.

Much thanks!


P.S. - I'll be sure to watch my versioning more closely going forward. :)
0
RAM SHAN
Top achievements
Rank 1
answered on 18 Dec 2009, 06:54 AM
I am having the same issue where the NeedDataSource is not firing when I am calling the report from my webpage. I am using Q3 2009 version of report controls. I am doing the same exact thing the original poster is doing and it does not work?

Please help!

Below are the details
//In my Report Classlibrary 
 
 public Report14Try1() 
        { 
            /// <summary> 
            /// Required for telerik Reporting designer support 
            /// </summary> 
            /// Verified that NeedDataSource is wired in Initializecomponent method below 
            InitializeComponent(); 
            //Tried this and still the report's NeedDataSource is not firing 
            //this.DataSource = null;             
        } 
 
//does not fire??? 
        private void Report14Try1_NeedDataSource(object sender, EventArgs e) 
        { 
//binding code to SQLDataAdapter 
 
        } 
 
 
//In WebPage where the above ClassLibrary is referenced 
ReportViewer1.Report = new Report14Try1(); 
        //Tried this and does not fire NeedDataSource in Report ClassLibrary 
        (ReportViewer1.Report as Report14Try1).DataSource = null
        ReportViewer1.DataBind(); 
        ReportViewer1.RefreshReport(); 

0
Steve
Telerik team
answered on 18 Dec 2009, 07:40 AM
Hello RAM SHAN,

There are two reasons for the NeedDataSource event not to fire:

  • the report has already been assigned a datasource either through the designer or the report constructor. Make sure it has no DataSource set!
  • the event is not hooked up to the report i.e. if you have used the events tab in VS, you should have similar line of code in the InitializeComponent() method:
    this.NeedDataSource += new System.EventHandler(this.Report1_NeedDataSource);
    If you have added the event handler by hand, you should wire it up as shown above.

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Bryan Strader
Top achievements
Rank 2
Answers by
Steve
Telerik team
Bryan Strader
Top achievements
Rank 2
RAM SHAN
Top achievements
Rank 1
Share this question
or