void ReportViewer1_RenderBegin(object sender, RenderBeginEventArgs args)
{
//single value parameter
args.ParameterValues["FormNumber"] = "ABC1";
args.ParameterValues["FormID"] = 10;
}
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
- 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.
- 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.
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!
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!
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.
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!
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.
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:
- Pass FormNumber to the report directly as parameter (you don't need report book).
- Create SqlDataSource that will get all the FormIDs for the current FormNumber
- Bind the report to that SqlDataSource (this way the detail section will repeat once for every FormID)
- Every repetition of the detail section will be the same as adding the same report to a report book numerous times
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.
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!
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.
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.
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!
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?
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!
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.
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:
var report = (Report1)ReportViewer1.Report;
report.ReportParameters[
"ParameterName"
].Value = TextBox1.Text
;
All the best,
Steve
the Telerik team