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.
Unfortunately, activation email could not send to your email. Please try again.

Bind 2 SQL DataSource to a single chart

Thread ID:

Created:

Updated:

Platform:

Replies:

124076 May 13,2016 09:13 AM May 17,2016 08:39 AM ASP.NET Web Forms 1
loading
Tags: Chart
Cory Wynn
Asked On May 13, 2016 09:13 AM

Hi,

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 08:39 AM

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. 

[ASPX] 

<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]"> 
        </asp:SqlDataSource> 

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" /> 
        <Series> 
            <ej:Series XName="x" YName="y" Type="Column">   
                <Tooltip Visible="true"></Tooltip>           
            </ej:Series> 
            <ej:Series XName="x" YName="y1" Type="Column"> 
                <Tooltip Visible="true"></Tooltip> 
            </ej:Series> 
             
        </Series>        
    </ej:Chart> 

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. 

Regards, 
Sanjith. 


CONFIRMATION

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.

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.

;