ReportParameter DataSource programmatically

4 posts, 0 answers
  1. Joao Paulo Grassi
    Joao Paulo Grassi avatar
    98 posts
    Member since:
    Feb 2011

    Posted 18 Aug 2011 Link to this post

    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!







  2. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 19 Aug 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Subrahmanya Kadiyala
    Subrahmanya Kadiyala avatar
    12 posts
    Member since:
    Nov 2009

    Posted 06 Oct 2011 Link to this post

    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
  5. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 11 Oct 2011 Link to this post

    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.

Back to Top