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

How to dynamically bind the series from code behind

Platform: ASP.NET Web Forms |
Control: Chart

How to dynamically bind the series from code behind?

Essential chart supports dynamically binding the series from code behind. To bind the series dynamically from code behind, create a sample by giving points in the code behind and bind the data source to the chart. After binding the data source, create a series object using code behind. In the series, you must map the x and y values to the respective fields using the xName and yName properties, respectively. Then, add the series into the chart. Kindly find the code snippet below,

[ASP.NET]

//Assigning points in code behind

List<ChartData> data = new List<ChartData>();

data.Add(new ChartData(2005, 28));

data.Add(new ChartData(2006, 25));

data.Add(new ChartData(2007, 26));

data.Add(new ChartData(2008, 27));

data.Add(new ChartData(2009, 32));

data.Add(new ChartData(2010, 35));

           

//Assigning series in code behind

Series series = new Series();

series.XName = "Xvalue";

series.YName = "YValue1";

series.Name = "Dynamic Series";

series.Fill = "red";

this.Chart1.Series.Add(series);

 

//Binding Datasource to Chart

this.Chart1.DataSource = data;

this.Chart1.DataBind();

//Create chart in client-side

 

<ej:Chart ClientIDMode="Static" ID="Chart1" runat="server" IsResponsive="true" >

</ej:Chart>

 

screenshot:

Dynamically bounded the series from code behindSample link:  https://www.syncfusion.com/downloads/support/forum/140033/ze/webformsKB2007007198

 

 

 

2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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