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

Report parameter selected values as another report parameter's DataSource input

1 Answer 102 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
TR
Top achievements
Rank 1
TR asked on 16 Jan 2011, 05:51 PM
My report has as DataSource a stored procedure that needs some parameters in order to be executed.
The parameters should be applied by the user.

Both the disscussed parameters has store procedures as their datasource and are multiselectable.

The selected values of the first parameter should be combined to a string with ',' between the values,
That will be used as input to another sqlDataSource store procedure which is used in the DataSource
of a second report parameter.

I need to combine the values of the first parameter to 1 string, and to refresh the seconed datasource when the first was updated.

// First parameter: 
this.StorageSystemDataSource.ConnectionString = "...";  
this.StorageSystemDataSource.Name = "SystemDataSource";  
this.StorageSystemDataSource.SelectCommand = "dbo.GetSystemType";  
this.StorageSystemDataSource.SelectCommandType = Telerik.Reporting.SqlDataSourceCommandType.StoredProcedure; 
    
// Second parameter: 
this.SystemNameDataSource.ConnectionString = "..."; 
this.SystemNameDataSource.Name = "SystemNameDataSource"; 
this.SystemNameDataSource.Parameters.AddRange(new Telerik.Reporting.SqlDataSourceParameter[] { 
new Telerik.Reporting.SqlDataSourceParameter("@SystemTypes", System.Data.DbType.AnsiString, "=IIF(Parameters.SystemTypeParameter.Value(0) = -1, Nothing, Join(Parameters.SystemTypeParameter.Value, \",\"))")}); 
// is that the way to combine the values????
    
this.SystemNameDataSource.ProviderName = "System.Data.SqlClient"; 
this.SystemNameDataSource.SelectCommand = "dbo.GetSystemByTypes"; 
// I need to reactivate this stored procedure on each selection changes of the first parameter values.
this.SystemNameDataSource.SelectCommandType=Telerik.Reporting.SqlDataSourceCommandType.StoredProcedure;

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 19 Jan 2011, 05:42 PM
Hello TR,

It seems that you are after Cascading Parameters. The only difference is the you will need the following FormatArray User Function and will have to use the FormatArray for the second stored procedure parameter: = FormatArray(Parameters.Parameter2.Value)

public static string FormatArray(IList array)
{
    StringBuilder sb = new StringBuilder();
 
    foreach (object o in array)
    {
        if (sb.Length > 0)
        {
            sb.Append(", ");
        }
        sb.Append(o.ToString());
    }
 
    return sb.ToString();
}

Best wishes,
Peter
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
Tags
General Discussions
Asked by
TR
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or