NeedDataSource not firing when Preview Button Clicked in web form

6 posts, 1 answers
  1. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 19 Jan 2010 Link to this post

    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.
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 20 Jan 2010 Link to this post

    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.
  3. DevCraft banner
  4. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 20 Jan 2010 Link to this post

    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.

  5. Answer
    Steve
    Admin
    Steve avatar
    10941 posts

    Posted 20 Jan 2010 Link to this post

    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.
  6. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 20 Jan 2010 Link to this post

    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.
  7. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 20 Jan 2010 Link to this post

    IGNORE, FIXED.
Back to Top
DevCraft banner