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

ReportParameter DataSource programmatically

3 Answers 391 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Missing User
Missing User asked on 18 Aug 2011, 08:42 PM
Hello.
i Have 4 ReportParameters, in one of then i need to fill with a list of Projects, but the problem is, to get the Projects i need the PersonID,
that is in my second parameter.

 I tried do acess the parameter in the Constructor but it is null at that moment, and  in the NeedDataSource it's to late.

Is there a Way or a event to Acess the Parameter and use it to call my Method and fill my another parameter with the result List?

Thanks!







3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 19 Aug 2011, 11:53 AM
Hi Joao Paulo Grassi,

Please check out How-To: Cascading Parameters with applied filtering on data source level help article that elaborates on cascading parameters. Generally the article is written for SqlDataSource component, still you can easily adapt the suggested approach for a method with ObjectDataSource components.

You may find useful the Report Life Cycle help article.

Best wishes,
Peter
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Subrahmanya Kadiyala
Top achievements
Rank 1
answered on 07 Oct 2011, 12:54 AM
Hi,

I have a report viewer with couple of parameters in the Parameter area. These parameters are created in code. I want to cascade these parameters programmatically. How can i achieve that? I could not find any documentation that talks about cascading ReportParameters programmatically.

Thanks,
Jay
0
Peter
Telerik team
answered on 11 Oct 2011, 10:36 AM
Hi Subrahmanya Kadiyala,

We highly recommend creating the desired cascading parameters through the Report Designer first and then review the code in the InitializeComponent to see the internal structure. You may find useful How-To: Cascading Parameters with applied filtering on Report level

Additionally check out the following code snippet that shows how to set up cascading parameters in code:
ReportParameter reportParameter1 = new ReportParameter("FromDate", ReportParameterType.String, "");
ReportParameter reportParameter2 = new ReportParameter("ToDate", ReportParameterType.String, "");
reportParameter1.AvailableValues.DataSource = sqlDataSourceSubCategory;
reportParameter1.AvailableValues.DisplayMember = "= Fields.Name";
reportParameter1.AvailableValues.ValueMember = "= Fields.ProductSubcategoryID";
reportParameter1.Name = "SubCategory";
reportParameter1.Visible = true;
 
reportParameter2.AvailableValues.DataSource = sqlDataSourceProducts;
reportParameter2.AvailableValues.DisplayMember = "= Fields.ProductID";
reportParameter2.AvailableValues.Filters.AddRange(new Telerik.Reporting.Data.Filter[] {
new Telerik.Reporting.Data.Filter("=IIF(Fields.ProductSubcategoryID is null,0,ProductSubcategoryID )", Telerik.Reporting.Data.FilterOperator.Equal, "=Parameters.SubCategory.Value")});
reportParameter2.AvailableValues.ValueMember = "= Fields.Name";
reportParameter2.Name = "Products";
reportParameter2.Visible = true;
this.ReportParameters.Add(reportParameter1);
this.ReportParameters.Add(reportParameter2);

We will have in mind you consideration to improve the Telerik Reporting documentation with cascading parameters code.

Kind regards,
Peter
the Telerik team

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

Tags
General Discussions
Asked by
Missing User
Answers by
Peter
Telerik team
Subrahmanya Kadiyala
Top achievements
Rank 1
Share this question
or