We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Json web datasource at runtime example

Thread ID:





143696 Apr 1,2019 12:51 PM UTC Apr 2,2019 09:40 AM UTC Dashboard Platform 1
Tags: Dashboard SDK
David Crumb
Asked On April 1, 2019 12:51 PM UTC

is there an example of changing the datasource of a dashboard file at runtime?  In particular using a web data source with parameters in an asp.net mvc application.

Many thanks.


Renuka N [Syncfusion]
Replied On April 2, 2019 09:40 AM UTC

Hi David  
Thanks for contacting Syncfusion Support.  
 You can change the Connection string of a dashboard using onApplyConnection Event API. Please refer the following link  to pass the connection string in the event 
Note : Refer the Newtonsoft.Json assembly in addition to other assembly (Syncfusion.Dashboard.Encryption.dll) in your application. You can download NewtonSoft.json from here 
Since you are using the web data source, we have the below changes in the mentioned UG  
  1. Please use the modified below code snippet in controller of your application to generate the connection string for the dashboard created using web data source, instead of the below mentioned in UG.
 Modified Code Snippet: 
     ConnectionStringBuilder obj = new ConnectionStringBuilder(); 
     DashboardCryptoProvider provider = new DashboardCryptoProvider(EncryptionType.AES); 
     ConnectionParameters connectionParameter = new ConnectionParameters 
      Url : "", // Pass the web datasource url 
      UserName: "",  
      Password: "", 
      ConnectionProviderType connectionType = ConnectionProviderType.WebDataConnector; // Connection type used in the dashboard 
      OdbcDbmsType odbcType = OdbcDbmsType.None; // ODBC DBMS type, if any 
      Connection connectionName = new Connection { DataSources = new List<DataSourceConnectionString>() }; 
      connectionName.DataSources.Add(new DataSourceConnectionString 
      Name = "Northwind Traders Sales Analysis"// Nane of the Data Source while designing the Dashboard in the Dashboard Designer 
       ConnectionString = obj.GenerateConnectionString(connectionParameter, connectionType, odbcType) 
    ViewBag.EncryptedString = provider.DoEncryption(Converter.SerializeObject(connectionName)); // You can pass the encrypted String in the onApplyConnection event API to change the change connection String  
We will update the UG with the mentioned changes for changing connection string of the dashboard designed using web data source at the run time in our upcoming release. 
Please let us know, if you have any queries. 
Renuka N.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon