RadControls for ASP.NET AJAX 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.
CopyC#
using System;
using System.Configuration;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
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;
}
}
}
CopyVB.NET
Imports System
Imports System.Configuration
Imports System.Web.UI.WebControls
Imports Telerik.Web.UI
Imports Telerik.Charting
Imports System.Data.SqlClient
Imports System.ComponentModel
Namespace RadChartBinding
<DataObjectAttribute()> _
Public Class ProductsBO
<DataObjectMethodAttribute(DataObjectMethodType.[Select], True)>_
Public Shared Function GetProducts() As IEnumerable
Dim command As 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()
Dim reader As SqlDataReader = command.ExecuteReader()
Return reader
End Function
End Class
End Namespace
See Also