I have a Silverlight report viewer to render the report from a class library within the same solution as the Silverlight project, following your best practices guide for creating reports.
In general I need a report to connect to multiple database(s) based on user selected options in a Silverlight application. I also have a Report Parameter which runs a SQL query on the database and returns a list of data that will be used to filter the report data. I’m having difficulty dynamically changing the connection string to the database, the report parameter still points to the initial database set during design time. It seems the report parameter can be accessed only in need_datasource event, but the report parameter needs this connection string to display the list of data that will be used to filter the report data.
1) Is there a way we could set reportParameter AvailableValues.DataSource in the need_datasource event or dynamically.
2) Is there a way to pass this connection string into the constructor in order to set the reportParameter in the constructor. Setting the value here seems to work but I cannot pass a value into the constructor.
3) Is there different design approach that we should be using?
Thanks for your help in advance.
17 Answers, 1 is accepted
private List<SqlDataSource> _sqlDataSources;
private List<SqlDataSource> SqlDataSources
if (_sqlDataSources == null)
private void BuildSqlDataSourceList()
_sqlDataSources = new List<SqlDataSource>();
var fields = GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
foreach (var field in fields)
if (field.FieldType == typeof(SqlDataSource))
public void SetConnectionString(string connectionString)
foreach (var dataSource in SqlDataSources)
dataSource.ConnectionString = connectionString;
I need to be able to set the connection string (server and database name) just before the report is run.
What does Telerik recommend?
I posted this last Friday. Should I just send in a support ticked, or start a new thread?
I'd recommend opening a new support ticket with Telerik. We have a work around in place, we're going to have to revisit this later.
I submitted a new ticket today. I'll post back here with the solution...
As you probably know, there is no Reporting object on the Silverlight client (in the works for subsequent versions) and the reports reside on the server. However you can change the SqlDataSouce.ConnectionString with a Report Parameter:
- add a Report Parameter with Visibility set to false
- configure your SqlDataSource component as usual
- add the following User Function
- bind the used data item (Report, Table, Chart).DataSource property with Binding to the =ChangeConnectionString(ReportItem, Parameters.Parameter1.Value)
- finally you can set the ReportParameter.Value from Silverlight application as shown in the Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer
the Telerik team
If I go to the Telerik.Reporting.SqlDataSource I'm using. Then look under ConnectionString, it doesn't let me put in an expression like
Just that wizard pops up to create a string value.
I put the
public static SqlDataSource ChangeConnectionString
in my MyReport.cs file is this correct?
For the expression then put "= MyReports.MyReport.ChangeConnectionString(ReportItem,2)"
This is working for me thanks.
Thanks for coming up with a solution for us.
Is this approach possible with an ObectDataSource or would we have to take another angle if we needed to achieve the same without using a SqlDataSource?
You can change the ObjectDataSource properties in the same manner. Have you tried?
I have the following problem, the post code grade works for datasource set for the report, but not for the datasource parameters, can I change the data connections for parameters, or maybe preview in SL require a refresh.