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

Passing parameter to Report from Silverlight

10 Answers 386 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
luke
Top achievements
Rank 1
luke asked on 05 Jan 2011, 10:24 AM

var _rCli = new ReportServiceClient();
var dic = new  NameValueDictionary();
dic.Add("ShoppingListId", 10);

NameValueDictionary dev = new  NameValueDictionary();
dev.Add("OutputFormat", "JPEG");
     
_rCli.RenderAsync("IMAGE", "Test.ModulesReports", dev, dic);

Hi,

Im trying to pass parameter from silverlight application to my report like in code above. I definied ReportParameter at designer but its never updating to value which im passing. 


thanks for any advice.
 

10 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 06 Jan 2011, 02:27 PM
Hello Lukasz,

Currently the only way to pass value from the Silverlight client to the report which resides on the server is described in the Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer.

All the best,
Steve
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
0
luke
Top achievements
Rank 1
answered on 12 Jan 2011, 01:32 PM
rCli.RenderAsync("IMAGE", "Test.ModulesReports", dev, dic);
So, currently this function not working? What will happened with this parameters passed to this function? Is it possible to "catch" them before report is built?

thanks
0
Eric
Top achievements
Rank 1
answered on 18 Oct 2011, 09:08 PM
I have the same question.  I need to pass parameters to a report on my silverlight server, and I tried the exact thing as Luke.  I am not sure how to get the parameters on the server side to create the customized report.  In the server I tried getting the ReportParameters in the constructor, but they were empty.

If this isn't possible, how can I have a user press a button on a silverlight web front end, and have the server render and save a report based upon the information that the user was viewing on the silverlight front end.

I suppose I must use the report viewer on my client side?
0
Peter
Telerik team
answered on 21 Oct 2011, 01:27 PM
Hi Eric,

It seems that you had used the Report Parameter definition item instead of the processing counterpart. The definition report parameter value is actually the default value. However the sender of the event is always the processing counterpart of the data item and you can use it to access the processing report parameter that exposes the processing value.

Generally the report parameters are optimized for use in expressions. Still if you have to access the report parameter value in code we highly recommend to review the Using Report Parameters programmatically help article.

Kind regards,
Peter
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

0
Eric
Top achievements
Rank 1
answered on 24 Oct 2011, 04:06 PM
Do you have an example of how to use the processing counterpart of a data item to access the processing report parameter?
0
Peter
Telerik team
answered on 27 Oct 2011, 09:11 AM
Hi Eric,

The following code snippet illustrates how to gain the processing report report parameter's value:

private void Report1_NeedDataSource(object sender, System.EventArgs e)
{
    //Take the Telerik.Reporting.Processing.Report instance
    Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
    var processingValue = report.Parameters["ManagerID"].Value;
}

Kind regards,
Peter
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

0
Ramesh
Top achievements
Rank 1
answered on 10 Jan 2013, 11:03 AM
Hi Peter,
As in the thread I am using below code to send report parameters
var deviceInfo = new NameValueDictionary();
   //set any report parameter value if necessary
   var parameters = new NameValueDictionary();
   parameters.Add("AgentId", agentID);
   parameters.Add("ContactCategoryID", sCategory);
   parameters.Add("ContactTypeID", sType);
   parameters.Add("CarrierID", carrierID);
   parameters.Add("ProductID", productID);
   parameters.Add("ClientID", clientID);
   parameters.Add("PeriodUpto", this.PeriodUpto);
   parameters.Add("MinimumCommission", this.MinCommission);
   parameters.Add("SortExpression", this.SortExpression);
 
 
  var serviceClient = new ReportServiceClient(new Uri(App.Current.Host.Source, "../Services/ReportService.svc"));
  serviceClient.RenderAsync(format,
       "AIS_InsuranceCRM_CNetWeb.ReportLibrary.Comission.CommissionPayableReport, AIS_InsuranceCRM_CNetWeb.ReportLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
       deviceInfo,
       parameters);
   serviceClient.RenderCompleted += new EventHandler<RenderEventArgs>(serviceClient_RenderCompleted);

But in my report even if I try to look at processing report params, I do not get any value back. Please let me know how I can get the parameter values back in the report? I am not using Telerik report viewer.

Thanks
Ramessh SIngvi






0
Squall
Top achievements
Rank 1
answered on 10 Jan 2013, 03:00 PM
Hi,

You can access the parameter values with expression:
=Parameters.AgentId.Value

If you want to access the value from event:
http://www.telerik.com/help/reporting/designing-reports-parameters-programmatic-control.html

SN
0
Ramesh
Top achievements
Rank 1
answered on 10 Jan 2013, 03:54 PM
Let me try to explain again as you haven't really got the issue. From my silverlight app, I am calling the report(see my code snippet in earlier post) and also sending bunch of parameters in the "parameter" collection. I am however not getting those parameters values in the "report_NeedDatasource" event.
I need those params to query the database and bind the data to my report. I have tried both:
private void Report_NeedDataSource(object sender, EventArgs e)
{
    this.ReportParameters["AgentID"].Value

    ((Telerik.Reporting.Processing.Report)(sender)).Parameters["AgentID"].Value
}

but both are coming as null. Can you please put some insight on this.

Thanks
Ramessh Singvi

 

 

 

0
Squall
Top achievements
Rank 1
answered on 11 Jan 2013, 09:40 AM
Hi,

Your code seems correct but have in mind that the keys are case sensitive. I have noticed that once you refer the parameter as AgentID and the second time you use for key AgentId.

SN

Tags
General Discussions
Asked by
luke
Top achievements
Rank 1
Answers by
Steve
Telerik team
luke
Top achievements
Rank 1
Eric
Top achievements
Rank 1
Peter
Telerik team
Ramesh
Top achievements
Rank 1
Squall
Top achievements
Rank 1
Share this question
or