# Data Binding RadChart to a Database Object

> caution **RadChart** has been deprecated since Q3 2014 and is marked as obsolete as of the 2026 Q2 SP1 (v2026.2.708) release. This is the last release that includes the RadChart component — its source code will be removed from the assembly in the next release. We strongly recommend using [RadHtmlChart](https://www.telerik.com/products/aspnet-ajax/html-chart.aspx), Telerik's modern client-side charting component.
> To transition from RadChart to RadHtmlChart, refer to the following migration articles:
>
> * [Migrating Series](https://www.telerik.com/products/aspnet-ajax/documentation/controls/htmlchart/changes-and-backwards-compatibility/migrating-from-radchart-to-radhtmlchart/migrate-series-configuration)
> * [Migrating Axes](https://www.telerik.com/products/aspnet-ajax/documentation/controls/htmlchart/changes-and-backwards-compatibility/migrating-from-radchart-to-radhtmlchart/migrate-axes-configuration)
> * [Migrating Date Axes](https://www.telerik.com/products/aspnet-ajax/documentation/controls/htmlchart/changes-and-backwards-compatibility/migrating-from-radchart-to-radhtmlchart/migrate-date-axis-configuration)
> * [Migrating Databinding](https://www.telerik.com/products/aspnet-ajax/documentation/controls/htmlchart/changes-and-backwards-compatibility/migrating-from-radchart-to-radhtmlchart/migrate-data-binding-configuration)
> * [Features parity](https://www.telerik.com/products/aspnet-ajax/documentation/controls/htmlchart/changes-and-backwards-compatibility/migrating-from-radchart-to-radhtmlchart/migrate-functionalities---features-and-series-types-parity)
>
> Explore the [RadHtmlChart documentation](https://www.telerik.com/products/aspnet-ajax/documentation/controls/htmlchart/overview) and online demos to determine how it fits your development needs.

To bind to a database, create a data source object, assign the data source to the RadChart and call the RadChart DataBind() method.

![RadChart bound to a SqlDataSource](https://www.telerik.com/products/aspnet-ajax/documentation/assets/8f40cb881935967499e87362359dbc26/radchart-building008.png)

The figure above shows a running example that starts with a default RadChart with a single Series. The example code:

* Creates a [SqlDataSource](https://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.aspx), adds it to the page, assigns the RadChart **DataSourceID** property and finally binds to the data source.

* Displays data for a database column by assigning the series DataYColumn or DataXColumn properties. In the example the "TotalSales" column is assigned to the DataYColumn property.

* Displays database column data in the X axis labels by assigning the column name to the **DataLabelsColumn**. The example assigns "CategoryName" to the DataLabelsColumn property.

> note Also note how the example sets the PlotArea.Appearance.Dimensions.Margins.Bottom to 30% and the PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle to 300 in order to provide room for the axis labels.

```C#
using System;
using System.Configuration;
using System.Web.UI.WebControls;
// Supports RadChart declaration
using Telerik.Web.UI;
// Supports RadChart objects, i.e. series, items
using Telerik.Charting;
namespace DatabindingExample
{
   public partial class _Default : System.Web.UI.Page
   {
	   protected void Page_Load(object sender, EventArgs e)
	   {
		   // create a datasource, add it to the page,
		   // and assign the datasource to RadChart
		   SqlDataSource sqlDataSource = new SqlDataSource();
		   sqlDataSource.ID = "myDataSource";
		   sqlDataSource.ConnectionString =
		   ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
		   sqlDataSource.SelectCommand =
		   "SELECT CategoryName, SUM(ProductSales) AS TotalSales FROM [Product Sales for 1997] GROUP BY CategoryName";
		   this.Page.Controls.Add(sqlDataSource);
		   RadChart1.DataSourceID = "myDataSource";
		   // Set the column for data and data labels:
		   // Each bar will show "TotalSales", each label along
		   // X-axis will show "CategoryName.
		   RadChart1.Series[0].DataYColumn = "TotalSales";
		   RadChart1.PlotArea.XAxis.DataLabelsColumn = "CategoryName";
		   // assign appearance related properties
		   RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 300;
		   RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color =
		   System.Drawing.Color.BlueViolet;
		   RadChart1.PlotArea.Appearance.Dimensions.Margins.Bottom =
		   Telerik.Charting.Styles.Unit.Percentage(30);
		   // bind to the datasource
		   RadChart1.DataBind();
	   }
   }
} 			
```

```VB
Imports System
Imports System.Configuration
Imports System.Web.UI.WebControls
' Supports RadChart declaration
Imports Telerik.Web.UI
' Supports RadChart objects, i.e. series, items
Imports Telerik.Charting
Namespace DatabindingExample
	Partial Public Class _Default
		Inherits System.Web.UI.Page
		Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
			' create a datasource and add it to the page
			Dim sqlDataSource As New SqlDataSource()
			sqlDataSource.ID = "myDataSource"
			sqlDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString
			sqlDataSource.SelectCommand = "SELECT CategoryName, SUM(ProductSales) AS TotalSales FROM [Product Sales for 1997] GROUP BY CategoryName"
			Me.Page.Controls.Add(sqlDataSource)
			' Set the column for data and data labels:
			' Each bar will show "TotalSales", each label along
			' X-axis will show "CategoryName.
			RadChart1.Series(0).DataYColumn = "TotalSales"
			RadChart1.PlotArea.XAxis.DataLabelsColumn = "CategoryName"
			' assign appearance related properties
			RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 300
			RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color = System.Drawing.Color.BlueViolet
			RadChart1.PlotArea.Appearance.Dimensions.Margins.Bottom = Telerik.Charting.Styles.Unit.Percentage(30)
			' assign the chart data source and bind it
			RadChart1.DataSourceID = "myDataSource"
			RadChart1.DataBind()
		End Sub
	End Class
End Namespace	
```

## See Also

* [Data Binding RadChart](https://www.telerik.com/products/aspnet-ajax/documentation/controls/chart/building-radcharts/data-binding-radchart)

* [Data Binding RadChart to an Array](https://www.telerik.com/products/aspnet-ajax/documentation/controls/chart/building-radcharts/data-binding-radchart-to-an-array)

* [Data Binding RadChart to a Generic List](https://www.telerik.com/products/aspnet-ajax/documentation/controls/chart/building-radcharts/data-binding-radchart-to-a-generic-list)

* [Data Binding RadChart to an ObjectDataSource](https://www.telerik.com/products/aspnet-ajax/documentation/controls/chart/building-radcharts/data-binding-radchart-to-an-objectdatasource)

* [Data Binding RadChart to an XML file](https://www.telerik.com/products/aspnet-ajax/documentation/controls/chart/building-radcharts/data-binding-radchart-to-an-xml-file)
