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

How to transfer parameter values from reportbook to added reports

13 Answers 323 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Manoj
Top achievements
Rank 1
Manoj asked on 20 Dec 2011, 09:11 PM
I am calling ReportBook from ReportViewer(in silverlight). In silverlight I am passing parameter to reportbook as follows.
void ReportViewer1_RenderBegin(object sender, RenderBeginEventArgs args)
  
{
  
//single value parameter 
  
args.ParameterValues["FormNumber"] = "ABC1";
  
args.ParameterValues["FormID"] = 10;
  
}
In ReportBook I am adding reports as follows.
class ReportBook2 : Telerik.Reporting.ReportBook
  
{
  
public ReportBook2()
  
{
  
this.Reports.Add(new Report1());
  
this.Reports.Add(new Report2());
  
this.Reports[0].DocumentMapText = "Dash Board";
  
this.Reports[1].DocumentMapText = "Product Sales";
  
}
  
}

Report1 needs parameter FormNumber. Report2 needs parameter FormID.
1. How to transfer these parameter to appropriate reports from reportbook?
2. Is there any way to add reports to reportbook from client(Silverlight) with appropriate parameters?


13 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 21 Dec 2011, 05:49 PM
Hello Manoj,
  1. The following KB article elaborates on passing values to report parameters from the Silverlight client:Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer.

  2. As for adding reports to the report book from the Silverlight client - this is not possible, as currently there is no Silverlight report definition i.e. the reports reside on the server.
Greetings,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Manoj
Top achievements
Rank 1
answered on 21 Dec 2011, 05:56 PM
In first question I asked for ReportBook. From reportviewer I have already passed parameters but in report book how to transfer these to appropriate report.
0
Steve
Telerik team
answered on 23 Dec 2011, 01:45 PM
Hello,

You use the RenderBegin eventhandler of the viewer. If you set unique parameter names for all reports then you can pass them as we already suggested in previous post. For example if you have 2 reports Report1 and Report2.
Report1 has parameters: "Param1_1", "Param1_2".
Report2 has 1 parameter "Param2_1".
Then when you want to pass these parameters you do the following:

void ReportViewer1_RenderBegin(object sender, RenderBeginEventArgs args)
       {
           args.ParameterValues["Param1_1"] = ...;  
           args.ParameterValues["Param1_2"] = ...;  
           args.ParameterValues["Param2_1"] = ...;  
       }

When report parameters' names are not unique and the Mergeable property is true (default), all report parameters with matching names would be applied the same value. If you need to pass different values to such parameters, set the Mergeable property to false and use the TelerikReportingRepeatingParameter
prefix for the report parameter name. More information is available in the Report Book Parameters help article.
Greetings,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Manoj
Top achievements
Rank 1
answered on 26 Dec 2011, 09:11 PM

I am having one report which is taking parameters 'FormId' and 'FormNumber'. I need to pass one number 'FormNumber' from

reportviewer to reportbook. In reportbook I want to call database to get FormIds. I need to add as many reports as many

FormIDs retrieved from db.

Report x = new PolicyDocuments.Template1.Rpt_Template1();
x.Report.ReportParameters["FormID"].Mergeable = true;
x.Report.ReportParameters["FormID"].Value = "194"; //FormID 1 got from db in reportbook
this.Reports.Add(x);
  
Report y = new PolicyDocuments.Template1.Rpt_Template1();
y.Report.ReportParameters["FormID"].Mergeable = true;
y.Report.ReportParameters["FormID"].Value = "505"; //FormID 2 got from db in reportbook
this.Reports.Add(y);
.
.
.//Repeting as many times as many FormIDs
.

- What is the syntex for getting 'FormNumber' parameter in Reportbook so can get FormIds from Database as per FormNumber.
- How can I ensure each report is receiving two parameters one 'FormNumber' (same for all reports, passed from

reportviewer) another 'FormID' which I want to pass from ReportBook.

0
Steve
Telerik team
answered on 28 Dec 2011, 12:53 PM
Hello,

As my colleague has explained in the first post, you can't use data from the Silverlight client in Telerik Report, because the data is on the client, while the reports reside on the server. The remote access to the Telerik Reporting Engine is enabled through the Telerik Reporting Service which acts as a communication interface between the client programs and the report server.
In short, adding reports to a report book at runtime is not possible with the current implementation of the Silverlight report viewer.

Greetings,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Manoj
Top achievements
Rank 1
answered on 28 Dec 2011, 07:57 PM
Please try to understand my query. I am adding reports at server in reportbook. And it is working fine. My question is for parameters.


I am having one report which is taking parameters 'FormId' and 'FormNumber'. I need to pass one number 'FormNumber' from
reportviewer to reportbook. In reportbook I want to call database to get FormIds. I need to add as many reports as many FormIDs retrieved from db.
Server Code:

[Description("A collection of Product-related reports")]
   public partial class Reportbook1 : Telerik.Reporting.ReportBook
   {
       public Reportbook1()
       {
           //Logic to get FormIDs from Database as per FormNumber
           int[] arr = MyDAO.getFormIDs(PassedParameterFromCient.FormNumber); //Please suggest syntex for PassedParameterFromCient
           Report x = new PolicyDocuments.Template1.Rpt_Template1();
           x.Report.ReportParameters["FormID"].Mergeable = true;
           x.Report.ReportParameters["FormID"].Value = arr[0]; //FormID 1 got from db in reportbook 
           this.Reports.Add(x);
           Report y = new PolicyDocuments.Template1.Rpt_Template1();
           y.Report.ReportParameters["FormID"].Mergeable = true;
           y.Report.ReportParameters["FormID"].Value = arr[1]; //FormID 2 got from db in reportbook 
           this.Reports.Add(y);
           this.Reports[0].DocumentMapText = "Template1";
           this.Reports[1].DocumentMapText = "Template2";
       }
   }

Client Code:
void ReportViewer1_RenderBegin(object sender, RenderBeginEventArgs args)
        {
             args.ParameterValues["PolicyNumber"] = CurrentView.txtPolicyNumber.Text;
            //args.ParameterValues["FormID"] = CurrentView.cbFormName.SelectedValue; //Will pass from ReportBook
        }


- What is the syntex for getting 'FormNumber' parameter in Reportbook so can get FormIds from Database as per FormNumber.
- How can I ensure each report is receiving two parameters one 'FormNumber' (same for all reports, passed from
reportviewer) another 'FormID' which I want to pass from ReportBook.
0
Elian
Telerik team
answered on 30 Dec 2011, 02:22 PM
Hi,

What you want:
Pass FormNumber to ReportBook from ReportBook get many FormID and create the corresponding number of reports and add them to the report book. 
However this is dynamic operation and as said before, you cannot add reports dynamically in report book from Silverlight.  

A possible solution:
Rework your report to achieve the following:
  1. Pass FormNumber to the report directly as parameter (you don't need report book). 
  2. Create SqlDataSource that will get all the FormIDs for the current FormNumber
  3. Bind the report to that SqlDataSource (this way the detail section will repeat once for every FormID)
  4. Every repetition of the detail section will be the same as adding the same report to a report book numerous times
You can also use sub-reports (add them to a blank report in the same manner with datasource and pass the current FormID as parameter).

Look at our List Bound demo. Each row (car) is a detail section and it repeats as many times as the cars are. You can do it in the same manner with your report (repeat it as many times as the FormID's are for the current FormNumber).
Also look at the Invoice demo which implements master-detail report style using SubReport item.

Greetings,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Manoj
Top achievements
Rank 1
answered on 12 Jan 2012, 11:29 PM

Thanks for suggestions. Sorry for returning late. I was out so could not reply.

For my requirement reportbook is good approach. I don't want to add reports from silverlight. So again repeating my question.
- What is the syntax for receiving 'FormNumber' parameter in Reportbook so can get FormIds from Database as per FormNumber.
I have tried somthing like this but not working.

[Description("A collection of Product-related reports")]
 public partial class Reportbook1 : Telerik.Reporting.ReportBook
 {
     private Telerik.Reporting.SqlDataSource sqlDataSource1;
     public Reportbook1()
     {
          this.sqlDataSource1 = new Telerik.Reporting.SqlDataSource();
         this.sqlDataSource1.ConnectionString = "Reporting.Properties.Settings.briteconnection";
         this.sqlDataSource1.Name = "sqlDataSource1";
         this.sqlDataSource1.Parameters.AddRange(new Telerik.Reporting.SqlDataSourceParameter[] {
         new Telerik.Reporting.SqlDataSourceParameter("@FormListMasterID", System.Data.DbType.Int32, "=Parameters.FormID.Value")});
         this.sqlDataSource1.SelectCommand = "dbo.Report_Rpt_Template1";
         this.sqlDataSource1.SelectCommandType = Telerik.Reporting.SqlDataSourceCommandType.StoredProcedure;
         //dont know how to get returned collection from database.

Still not understanding why are you guys having hard time in understanding my simple question even I have provided code snippet.

It will be great if you provide some small code sample.

 

0
Elian
Telerik team
answered on 17 Jan 2012, 04:02 PM
Hi Manoj,

We do understand your question, however that is not possible. The ReportBook is simply a collection of reports, it cannot be used in the way you are trying to (assigning data-sources or using parameters). All that the ReportBook does is to hold reports that will be displayed by the viewer and cannot manipulate them in any way.
So, once again, for the layout you want to achieve, refer to my previous post.

Greetings,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Manoj
Top achievements
Rank 1
answered on 17 Jan 2012, 08:03 PM

Thanks for clearing the things. Second closest workaround can be similar to Invoice demo. I can create Invoice demo kind of report in popup window. Good thing with Invoice demo is, user can select report by name similar to reportbook.

-          As per requirement user should be able to export all reports to single PDF document at single button click from parent silverlight screen even without opening report window. Exported documents should go to some hardcoded network path. Is this possible with this approach?

0
Accepted
Elian
Telerik team
answered on 19 Jan 2012, 05:38 PM
Hi,

Exporting Report Programmatically in Silverlight - this is the code you need to export reports programmatically from Silverlight. After the button is clicked a Save dialog will appear where to save the file and how to name it (the dialog cannot be avoided).

All the best,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Chubi
Top achievements
Rank 1
answered on 19 Feb 2012, 05:14 PM
I want to generate invoice report by passing parameter value from a textbox (from windows form) to telerik reporting.
The parameter value which I have used in telerik reporting is invoice number, I don't want to give any option to end user to select invoice number manually. because it is an automatic increasing value when user creates a new invoice report. So I want to show sold product details of current invoice number.
0
Steve
Telerik team
answered on 20 Feb 2012, 12:55 PM
Hello Chubi,

There is nothing special in this scenario that concerns the report itself. In the code-behind of your Windows Form, you simply assign values to the parameters:

Copy Code
var report = (Report1)ReportViewer1.Report;
report.ReportParameters["ParameterName"].Value = TextBox1.Text;

All the best,
Steve
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
General Discussions
Asked by
Manoj
Top achievements
Rank 1
Answers by
Elian
Telerik team
Manoj
Top achievements
Rank 1
Steve
Telerik team
Chubi
Top achievements
Rank 1
Share this question
or