Binding to ObjectDataSource at Run-Time
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.
Once a business object with appropriate attributes has been created you can bind to it in code at run-time. The steps are:
Set the ObjectDataSourceTypeName property to name of the object class, in this example "RadChartBinding.ProductsBO" (Be sure to qualify the class name with the namespace).
Set the SelectMethod to the method marked by the DataObjectMethodAttribute.
The code below demonstrates binding to an ObjectDataSource that consumes an example object defined in the topic "Creating an Object that can be consumed by ObjectDataSource".
ObjectDataSource ods = new ObjectDataSource();
ods.SelectMethod = "GetProducts";
ods.TypeName = "RadChartBinding.ProductsBO";
RadChart1.DataSource = ods.Select();
RadChart1.Series[0].DataYColumn = "QuantityInStock";
RadChart1.PlotArea.XAxis.DataLabelsColumn = "Name";
RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 8);
RadChart1.DataBind();
Dim ods As New ObjectDataSource()
ods.SelectMethod = "GetProducts"
ods.TypeName = "RadChartBinding.ProductsBO"
RadChart1.DataSource = ods.[Select]()
RadChart1.Series(0).DataYColumn = "QuantityInStock"
RadChart1.PlotArea.XAxis.DataLabelsColumn = "Name"
RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font = New System.Drawing.Font("Arial", 8)
RadChart1.DataBind()