New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Creating an Object that can be Consumed by ObjectDataSource

RadChart has been replaced by RadHtmlChart, Telerik's client-side charting component. If you are considering RadChart for new development, examine the RadHtmlChart documentation and online demos first to see if it will fit your development needs. If you are already using RadChart in your projects, you can migrate to RadHtmlChart by following these articles: Migrating Series, Migrating Axes, Migrating Date Axes, Migrating Databinding, Features parity. Support for RadChart is discontinued as of Q3 2014, but the control will remain in the assembly so it can still be used. We encourage you to use RadHtmlChart for new development.

See the code below for an example object that can be consumed by ObjectDataSource. Your object needs to be marked with the DataObjectAttribute for the object to be seen by Data Source Configuration Wizard. It also needs a method to select data marked by the DataObjectMethodAttribute (see GetProducts() method in the code sample).

See Data Binding RadChart to an ObjectDataSource for an example of how to use this object for binding.

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;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Collections;
namespace RadChartBinding
{
	[DataObjectAttribute()]
	public class ProductsBO
	{
		[DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
		public static IEnumerable GetProducts()
		{
			SqlCommand command = new SqlCommand();
			command.Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
			command.CommandText = "SELECT CategoryName, SUM(ProductSales) AS TotalSales FROM [Product Sales for 1997] GROUP BY CategoryName";
			command.Connection.Open();
			SqlDataReader reader = command.ExecuteReader();
			return reader;
		}
	}
}

See Also

In this article
See Also
Not finding the help you need?
Contact Support