Creating an Object that can be Consumed by ObjectDataSource
RadChart has been deprecated since Q3 2014 and is no longer recommended for use, as it does not support modern browsers. We strongly recommend using RadHtmlChart, Telerik's modern client-side charting component. To transition from RadChart to RadHtmlChart, refer to the following migration articles:
Explore the RadHtmlChart documentation and online demos to determine how it fits your development needs.
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.
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;
}
}
}