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

NeedDataSource not firing when Preview Button Clicked in web form

5 Answers 341 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brian Mains
Top achievements
Rank 1
Brian Mains asked on 19 Jan 2010, 03:24 PM
Hello,

Go to the report in the browser, in my app, and hit save.  That works OK.  But when I go to change the params and hit the preview button, it's not firing the needdatasource event.  So I was wondering if there is something else I need to do in order for that to happen?  Do I need to force a postback, or something?

Thanks.

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 20 Jan 2010, 09:01 AM
Hi Brian,

The Adding a Data Source through NeedDataSource report event help article describes that the event is fired only if the report has no data source set and you should use the processing report object in that event (more on processing vs. definition available in Understanding Events article).
If the above is met, the NeedDataSource event should be fired on clicking the preview button.

Regards,
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.
Celeste
Top achievements
Rank 1
commented on 01 Mar 2024, 08:23 PM

The 'Adding a Data Source...' link is dead. Please fix.
Todor
Telerik team
commented on 05 Mar 2024, 04:05 PM

Hi Celeste,

Thank you for discovering the dead link and sharing the problem with us.

Here is the correct link Using the NeedDataSource Event to Connect to Data.

We will fix also the above URL to point to the same article.

0
Brian Mains
Top achievements
Rank 1
answered on 20 Jan 2010, 02:03 PM
Hey,

The data source property in the designer properties window is set to (none).  I set this.DataSource = null; in the constructor after intiializecomponent.  I have a dataset/dataadapter in the component window on the report, and in need data source, I do:

 

private

 

void SeekTeachFundsPerSiteStaff_NeedDataSource(object sender, EventArgs e)

{

 

this.testDataSet.TestReport.Rows.Clear();

 

this.TestDataSetTableAdapter.FillTestData(

this.testDataSet.TestReport,

(int?)this.ReportParameters["Key"].Value,

(DateTime?)(this.ReportParameters["StartDate"].Value),

(DateTime?)(this.ReportParameters["EndDate"].Value));

this.DataSource = this.testDataSet.TestReport;

}


There is data that comes back; the key value comes from a drop down list.  That drop down gets populated in the constructor.  I select a value from the drop down, enter a start and end date, hit the preview button, and I get a valid resultset back.  Event fires and all.  I change the value in the drop down and hit preview again, and it fires the same resultset in triplicate (which I don't know how that happens).  So it doesn't fire the second preview click; it doesn't recognize the value change...

So is this correct or incorrect?  Also I tried using the table adapter as the datasource, but no luck either.

0
Accepted
Steve
Telerik team
answered on 20 Jan 2010, 02:59 PM
Hi Brian,

It seems you have not read our previous reply and referenced articles carefully. We explicitly state that you should use the processing report object i.e.:

wrong
private void SeekTeachFundsPerSiteStaff_NeedDataSource(object sender, EventArgs e)
{
.....
this.DataSource = this.testDataSet.TestReport;
}

correct
private void SeekTeachFundsPerSiteStaff_NeedDataSource(object sender, EventArgs e)
{
.....
Telerik.Reporting.Processing.Report rpt = (Telerik.Reporting.Processing.Report)sender;
rpt.DataSource = testDataSet.TestReport;
}

We kindly ask you to check our documentation and KB sections prior opening an inquiry.
You can browse the public forum as well in order to find specific information/code sample concerning an aspect of the Reporting features. There are numerous threads which can get you started/assist you through the development process.

All the best,
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
Brian Mains
Top achievements
Rank 1
answered on 20 Jan 2010, 03:07 PM
Hello,

Thanks I just caught that.  Using that did work.  Though the confusing part is that you set this.DataSource to null in the constructor, but use the processing report in need data source.

Thanks.
0
Brian Mains
Top achievements
Rank 1
answered on 20 Jan 2010, 06:08 PM
IGNORE, FIXED.
Tags
General Discussions
Asked by
Brian Mains
Top achievements
Rank 1
Answers by
Steve
Telerik team
Brian Mains
Top achievements
Rank 1
Share this question
or