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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Bind 2 SQL DataSource to a single chart

Thread ID:





124076 May 13,2016 01:13 PM UTC May 17,2016 12:39 PM UTC ASP.NET Web Forms 1
Tags: Chart
Cory Wynn
Asked On May 13, 2016 01:13 PM UTC


Is it possible to bind 2 differant SQL DataSources to a single chart? So for each <ej:series> you would have a different SqlDataSource

<ej:Series Name="DataSource1" XName="DataSource1" YName="DataSource1"></ej:Series>
<ej:Series Name="DataSource2" XName="DataSource2" YName="DataSource2"></ej:Series>
<asp:SqlDataSource ID="DataSource1" runat="server" ConnectionString="Connection" SelectCommand="QUERY"></asp:SqlDataSource>
<asp:SqlDataSource ID="DataSource2" runat="server" ConnectionString="Connection" SelectCommand="QUERY"></asp:SqlDataSource>

Sanjith Kesavan [Syncfusion]
Replied On May 17, 2016 12:39 PM UTC

Hi Cory, 

Thanks for contacting Syncfusion support. We have analyzed your query. Currently we are not having support for binding 2 different SQL datasources to a single chart. But we can bind the table which containing multiple columns as the datasource for the chart and we can use these different column values for series. Please find the below code example. 


<asp:SqlDataSource ID="SqlData" runat="server"  
            ConnectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Incident\Samples\17-5-16\ASP\WebApplication2\WebApplication2\App_Data\Windowsformdata.mdf;Integrated Security=True;Connect Timeout=30" 
            SelectCommand="SELECT * FROM [table2]"> 

In the above code, we have get the data from “table2”. Table2 is containing 3 columns(x,y,y1).  

<ej:Chart runat="server" DataSourceID="SqlData" XName="x" YName="y" ID="ChartSample">    
         <PrimaryXAxis ValueType="Category" LabelPlacement="BetweenTicks" IntervalType="Days" /> 
            <ej:Series XName="x" YName="y" Type="Column">   
                <Tooltip Visible="true"></Tooltip>           
            <ej:Series XName="x" YName="y1" Type="Column"> 
                <Tooltip Visible="true"></Tooltip> 

In the above code, we have bound the “table2” as datasource for the chart using its ID in “DataSourceID”. For the first series we have bound x as  xname and y as yname and for the second series we bound x as xname and y1 as yname. Now the chart will render like below.  

In the below link, we have attached sample for your reference. 



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

or the page will be automatically redirected to 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