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

Using Report Parameters in the Header

11 Answers 176 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 1
Darren asked on 06 Aug 2009, 06:33 PM
Hi,

I have looked at some of the report videos.  I am still not clear about how to use the parameters that one sets on the reports.  I have a couple of DateTime parameters which appear on my report.  They look cool with the Date Picker, but how do I send these parameters to the report?  When I change it does not seem to have any effect on the report.  My SQL query does have parameters in it and they have default values.

Thanks,
Darren

11 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 07 Aug 2009, 03:58 PM
Hello Darren ,

Generally there are two ways of applying the parameters values:
  • Through your own user interface or any other means (e.g. query string). To pass the values you can use the solution provided in the following video: Design Time Support for Parameterized Queries.
  • Through the report parameters defined in the ReportParameters collection of the report. To "apply" changes to the date shown in the report, you would need to use our Filtering as well as the report parameters go hand in hand with the filtering.What you should know, is that our built-in filtering is performed on the whole datasource i.e. if you have a large datasource the performance would decrease dramatically.
Regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Darren
Top achievements
Rank 1
answered on 07 Aug 2009, 04:37 PM
HI Steve,

I saw that video before and it helped.  I'm working on a web report so it's a bit more complicated. I do have a large data source so filtering it is out.  Can I still use the report parameters that show up in the header section and hook into the preview button or do I need to make my own parameter controls on the ASPX page and a button for refreshing the report?

Also I notice that I don't have a RefreshReport method on my ReportViewer control.  How do I refresh the report?

Thanks,
Darren
0
Steve
Telerik team
answered on 10 Aug 2009, 07:55 AM
Hello Darren ,

The value of the built-in report parameters can be used for whatever you find necessary. Here is an example how to set its value to the parameter of the select command:

private void MyReport_NeedDataSource(object sender, System.EventArgs e)         
{         
  //Transfer the ReportParameter value to the parameter of the select command         
  this.sqlDataAdapter1.SelectCommand.Parameters["@MyParam"].Value = this.ReportParameters["MyParam"].Value;         
         
  //Take the Telerik.Reporting.Processing.Report instance and set the adapter as        
  //it's DataSource         
  Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;         
  report.DataSource = this.sqlDataAdapter1;         
}       

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Darren
Top achievements
Rank 1
answered on 10 Aug 2009, 11:41 AM
Hi Steve,

Sorry to be such a noob, but where is the NeedsDataSource event?

Also, on my RadGridView, Visual Studio 2008 is telling me it can't find a DataMemberPath for the GridViewColumn object.  Where is that?

I appreciate your help.  Telerik support is awesome!

Thanks,
Darren
0
Steve
Telerik team
answered on 10 Aug 2009, 12:12 PM
Hi Darren ,

The NeedDataSource event "belongs" to the report i.e. it can be found in the events tab in the property grid when the report is selected - you can use the Report selector from the Report Designer. This event occurs at the start of the report processing if the report has no data source set.

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Darren
Top achievements
Rank 1
answered on 10 Aug 2009, 12:32 PM
Thanks for the reply, Steve!

I can not find the DataMememberPath or the NeedDataSource event.  Where would they be?

Thanks,
Darren
0
Steve
Telerik team
answered on 10 Aug 2009, 01:39 PM
Hello Darren ,

There must be some confusion here - the NeedDataSource event is a report event and not an event of the RadGridView. It would be best if you open a separate ticket that is in the appropriate category (in this case RadGridView for Winforms), so we do not mix the issues and product categories in our replies and keep our correspondence clean.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Darren
Top achievements
Rank 1
answered on 10 Aug 2009, 01:43 PM
Hi Steve,

Sorry!  That was my fault.  I found the NeedDataSource event.

I will open a ticket for the other problem.

Thanks,
Darren
0
Darren
Top achievements
Rank 1
answered on 10 Aug 2009, 03:48 PM
Hi,

I got the NeedDataSource event wired up but it is not firing.  What am I doing wrong now?

Thanks,
Darren
0
Accepted
Steve
Telerik team
answered on 11 Aug 2009, 07:44 AM
Hi Darren ,

As explained two posts down, this event occurs at the start of the report processing if the report has no data source set. Also make sure the event is indeed wired up properly i.e. you should have the following line in the InitializeComponent() method if you've added it through the report property grid:

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

We kindly ask you to read carefully our explanations and documentation articles, as they stress on all important aspects you need to know about a feature.

Regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Darren
Top achievements
Rank 1
answered on 12 Aug 2009, 02:53 PM
Hi Steve,

Sorry!  Multitasking too much.

Anyway, I did it like this:

    public partial class EventMetrics2 : Telerik.Reporting.Report 
    { 
        public EventMetrics2() 
        { 
            InitializeComponent(); 
 
            this.DataSource = null
 
            try 
            { 
            } 
            catch (System.Exception ex) 
            { 
                System.Diagnostics.Debug.WriteLine(ex.Message); 
            } 
        } 
 
        private void EventMetrics2_NeedDataSource(object sender, EventArgs e) 
        { 
            this.gateSureEventMetrics2DataSetTableAdapter1.Fill(this.gateSureEventMetrics2DataSet.GateSureEventMetrics2DataSetTable, (DateTime?)this.ReportParameters["DateFrom"].Value, (DateTime?)this.ReportParameters["DateTo"].Value); 
 
            Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender; 
            report.DataSource = this.gateSureEventMetrics2DataSet; 
        } 
    } 
 

This works.  Does that look okay to you?  I like this because I can leave the designer alone.

Thanks,
Darren
Tags
General Discussions
Asked by
Darren
Top achievements
Rank 1
Answers by
Steve
Telerik team
Darren
Top achievements
Rank 1
Share this question
or