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

How can i post parameter to the reportViewer from silverlight

24 Answers 547 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
wang zhong
Top achievements
Rank 1
wang zhong asked on 02 Feb 2010, 02:36 AM
Hi all
I want post a parameter to the reportViewer,
who can help me?
thank you~~

24 Answers, 1 is accepted

Sort by
0
wang zhong
Top achievements
Rank 1
answered on 02 Feb 2010, 07:36 AM
At the silverlight side
the Class report does not support
" this.ReportViewer1.Report.ReportParameters["MyParam"].Value = "";"
It does not have the property ReportParameters,
So i can't post the parameter to the report.
0
Accepted
Steve
Telerik team
answered on 02 Feb 2010, 08:48 AM
Hello wang zhong,

Are you using the web report viewer or the native Silverlight viewer we introduced in Q3 2009? If the first, then use a code like this:

Telerik.Reporting.Report report = (Telerik.Reporting.Report)this.ReportViewer1.Report;
report.ReportParameters["MyParam"].Value = <your_value>;

If you are using the Silverlight viewer, please review the following KB article: Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer.

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
wang zhong
Top achievements
Rank 1
answered on 03 Feb 2010, 02:13 AM
thanks very much,i will try it.
If any question i will ask you again~~
thanks again
0
John Cobb
Top achievements
Rank 1
answered on 16 Feb 2010, 09:25 PM
I attempted to follow the document you referred to: " Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer.".  The paramters I assigned were not passed from the viewer to the report.  The report does not even complain about having null parameters.  I double checked the parameter names to make sure there were no misspellings.  The only difference that I see is that I am exposing the viewer in a silverlight child window.  Is this a issue?

-John Cobb
0
Steve
Telerik team
answered on 17 Feb 2010, 05:21 PM
Hi John,

If the RenderBegin event handler is being called then there is no reason why the parameters would not be passed. Try debugging your application to see what you have for args.ParameterValues["YourParam"].
If you are having trouble identifying what is the problem, please open a support ticket and attach a sample runnable project that we can review.

All the best,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
John Cobb
Top achievements
Rank 1
answered on 18 Feb 2010, 02:03 AM
Thanks.  I did some testing and I did determine that the parameters are being passed as you said.  However, is there a way to access the args object from inside the report constructor?  My datasource is a SQLServer function that requires a start date and an end date.

    public partial class ReportState : Telerik.Reporting.Report  
    {  
        public ReportState()  
        {  
            /// <summary>  
            /// Required for telerik Reporting designer support  
            /// </summary>  
            InitializeComponent();  
 
            var rr = new ReportRepository();  
            var rl = rr.GetAll(new DateTime(2010, 1, 1), new DateTime(2010, 2, 28));  
            this.table1.DataSource = rl;  
        }  
    } 


     In the call to rr.GetAll(...), I would like to replace the 2 parameters with the parameters I set in the args object in the RenderBegin event.  Is this possible?  When I access this.ReportParameters, I get the report parameter definitions.  Is there a way to programmatically change the ReportParameter.Value in the RenderBeginEvent?

0
Steve
Telerik team
answered on 22 Feb 2010, 05:48 PM
Hello John,

You can't access parameters in the report constructor because they are not set until after the instance is created. This is not something specific to Telerik Reporting, but applicable for any .NET class.

Kind regards,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
John Cobb
Top achievements
Rank 1
answered on 22 Feb 2010, 05:54 PM
If you are passing the args object through the WCF service and then invoking the report constructor, why isn't this object accessible by the constructor?  During my debugging, the RenderBegin event is called before the constructor for the report is called.  This suggests that the args obj exists on the server at this point but is simply not exposed.
0
Charlie
Top achievements
Rank 2
answered on 26 Feb 2010, 12:29 AM
Hey John,

I am having the same problem that you are having.   I was expecting to be able to get the values in the constructor as well.  I am using Business Objects for my report data source.
0
John Cobb
Top achievements
Rank 1
answered on 26 Feb 2010, 02:58 PM
Turns out that if you use the NeedDataSource event, the parameters are available there via this.ReportParameters.  Set the DataSource = null in the constructor and set the reports NeedDataSource to some function.  My problem at that point is that I am using NHibernate which requires the current HttpContext from my original web call.  Since the NeedDataSource event handler is being processed in a different thread, the HttpContext is not available. 

    public partial class ReportU : Telerik.Reporting.Report  
    {  
 
        public ReportU()  
        {  
            /// <summary>  
            /// Required for telerik Reporting designer support  
            /// </summary>  
            InitializeComponent();  
 
            this.DataSource = null;  
        }  
 
        private void ReportU_NeedDataSource(object sender, System.EventArgs e)  
        {  
 
            var sqlhelper = new SQLHelper();  
 
            var sqlParms = new Dictionary<stringobject>();  
            sqlParms["startDate"] = (DateTime)this.ReportParameters["StartDate"].Value;  
            sqlParms["endDate"] = (DateTime)this.ReportParameters["EndDate"].Value;  
 
            var rl = sqlhelper.GetReportRowList(sqlParms);  
 
            this.DataSource = rl;  
        }  
    }  

The SQLHelper class is just a wrapper around standard .Net SqlClient class methods.  Set the NeedDataSource event handler in the designer properties for the report.

John
0
Charlie
Top achievements
Rank 2
answered on 26 Feb 2010, 04:19 PM
Thanks John.  This is exactly what I was looking for.  I wish there ReportParameter supported custom .NET Objects as well since it is use in a WCF Service.

Thanks,

Charlie J.
0
rafal piotrowski
Top achievements
Rank 1
answered on 07 Mar 2010, 03:20 PM
Hi,
I have problem with this solution, as after setting again the DataSource of the report, the report does not respond to the change (i.e. it does not use the data supplied)!!!!
Any idea how to solve this?
/rp
0
rafal piotrowski
Top achievements
Rank 1
answered on 07 Mar 2010, 03:29 PM
I found the problem

int the NeedDataSource event handler method I was setting the report datasource by 

this.DataSource = aDataSet;

instead one need to do the following

(sender as Telerik.Reporting.Processing.Report).DataSource = aDataSet;

Does anyone knows WHY?

regards
rp
0
Steve
Telerik team
answered on 08 Mar 2010, 09:16 AM
Hello rafal piotrowski,

The following help topics would answer your question:

Kind regards,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Amruta
Top achievements
Rank 1
answered on 28 Apr 2010, 01:02 PM
Hi,
Following is the scenario -
I have a silverlight application where i do some search for the given keyword and i get a list of items. I want to create a report for this list of items. I want to open the report on click of a link on xaml page. Also, i want to open the same report in separate browser for different search criteria (multiple reports using separate browser window).
I tried to host a reportviewer(Telerik.ReportViewer.WebForms) in a separate aspx page and i navigate to this aspx page in click event of the link. (i am able to open the report in separate windows on a click)
How can i pass the list of items (the search result) from xaml page to this report? Or is there any other way to accomplish this functionality? 

Can we pass a list of string variables from xaml to aspx or directly to the telerik report?
Regards. 
0
Greg Sipes
Top achievements
Rank 1
answered on 17 Feb 2011, 07:36 PM
Steve or John,
     Have there been any updates to this issue? I'm working in VB, but I followed John's idea by using the NeedDataSource event, but it is telling me that the object reference is not set to an instance of an object . I've checked my typing.....is it different threads? I'm pretty sure I've read just about every article and forum here on Telerik about the issue and I'm still stuck..... I put breakpoints on the RenderBegin event of the reportViewer, one on the constructor of the report with two parameters, and one on the NeedsDataSource event.
 The renderBegin event hits and I set the two parameters for the report's constructor
args.ParameterValues("sale") = SaleNo
        args.ParameterValues("custID") = CustomerID

Next, the NeedDataSource event is hit inside the report
SaleNo = DirectCast(Me.ReportParameters("sale").Value, Integer)
        CustomerID = DirectCast(Me.ReportParameters("custID").Value, String)


.....Why wouldn't the reports constructor with the two parameters be hit? But more importantly, when the NeedsDataSource event fires off, why aren't the two parameters that I supplied in the Me.ReportParameters collection?

Any help would be greatly appreciated!

0
raj
Top achievements
Rank 1
answered on 16 May 2011, 04:55 PM
Does someone have a working solution to pass parameter from client to report in server using silverlight? Though following all the  above mentioned steps i don seem to be getting .. Always this.reportparameters.count==0... Is telerik really having a functionality of sending parameters from client to web? Someone just help me out.. Im fed up.... :(
0
Greg Sipes
Top achievements
Rank 1
answered on 16 May 2011, 07:02 PM
I feel you Raj! I gave up on Telerik Reporting and went to SQL Reporting, which comes with SQL. Parameter passing is simple in SQL Reporting....
0
raj
Top achievements
Rank 1
answered on 17 May 2011, 06:35 AM
Hi Greg Sipes

                      I searched for this solution a lot over the net. There is no one to help here...

0
Steve
Telerik team
answered on 19 May 2011, 04:15 PM
Hi guys,

As far as we're aware SSRS do not offer a Silverlight report viewer. To provide the ability to specify the parameter values from the Silverlight client we have added an event to the Silverlight reportviewer control called RenderBegin. More information is available in the Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer help article.

Regards,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
raj
Top achievements
Rank 1
answered on 19 May 2011, 04:58 PM
Hi Steve...
                Im really sorry to say that im tired of the link you post everywhere programmattic initialisation bla bla bla.. That doesn't work..No values gets passed from client to web through your render begin. And as far as i have browsed through i never even found any example to do that.So could you please provide us any silverlight example which does reporting by passing parameters from client side..

Regards
Raj
0
Karlkim Suwanmongkol
Top achievements
Rank 1
answered on 19 May 2011, 06:31 PM
Hi Raj,
   The parameter passing in Silverlight does work. We have several projects utlizing that. One thing that I can suggest without seeing any of your code is to make sure that the "ReportParameters" property match all parameters that you want to pass. I always forget about that when I create a new report.
Good luck!
--karlkim
0
Stuart
Top achievements
Rank 1
answered on 31 Aug 2011, 01:21 AM
For the benefit of any others that come across this post - the report parameters are not directly available in the constructor of the report (I think it is mentioned somewhere here).

So, you need to use code like this:

public partial class Report : Telerik.Reporting.Report
{
    public Report()
    {
        InitializeComponent();
        this.NeedDataSource += (o, e) =>
        {
            foreach (var reportParameter in this.ReportParameters)
            {
                // Read out the value of the report parameter here.
            }
        };
    }
}

Hope that helps - it took me awhile to discover this.

Stuart


0
Brett
Top achievements
Rank 1
answered on 12 Mar 2012, 06:02 PM
I fought with this issue for a while as well.

I was futzing around with the reporting to see if I could make it do everything I needed (parameter passing included.)  as such I started with the overall program structure rather than making a fully-functional report.  I suspect that if I had learned how to create a complete report before I tried to reference it from silverlight, this would not have been an issue.

Anywho, this was the big "aha."  I hadn't seen this posted anywhere while trying to resolve my issue:  [report].ReportParameters needed to be specified at design time in addition to [sqlDataSource].Parameters.  in retrospect it seems silly I missed this, but that was my issue.

Silverlight passes its parameters into [report].ReportParameters.  I needed to configure the sqlDataSource to reference these values.

so in my case (All at design time):

- I created a sqlDataSouce that had @StartTime as a parameter in the query
- I Added "StartTime" as a ReportParameter to the Report
- back in the sqlDataSource "Parameters..." dialog I set @StartTime =Parameters('StartTime').Value

this worked, I danced a merry jig.
Tags
General Discussions
Asked by
wang zhong
Top achievements
Rank 1
Answers by
wang zhong
Top achievements
Rank 1
Steve
Telerik team
John Cobb
Top achievements
Rank 1
Charlie
Top achievements
Rank 2
rafal piotrowski
Top achievements
Rank 1
Amruta
Top achievements
Rank 1
Greg Sipes
Top achievements
Rank 1
raj
Top achievements
Rank 1
Karlkim Suwanmongkol
Top achievements
Rank 1
Stuart
Top achievements
Rank 1
Brett
Top achievements
Rank 1
Share this question
or