New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

LinqDataSource

This example shows how a RadHtmlChart can be bound to a LinqDataSource. The major properties are:

  • DataSourceID in the main tag sets the declarative data source for the entire chart. The DataSource property can be used for a programmatic data source if you create the connection in the code-behind.
  • DataFieldY for the series to point it to the desired column of the data source.
  • DataLabelsField for the x-axis labels to populate the items for the axis (it can also be applied to the y-axis).
  • DefaultVB.aspx
  • DefaultVB.aspx.vb
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="DefaultVB.aspx.vb" Inherits="Telerik.Web.Examples.HtmlChart.DataBinding.LinqDataSource.DefaultVB" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>

<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" OnSelecting="LinqDataSource1_Selecting">
    </asp:LinqDataSource>
    <div class="demo-container size-wide">
        <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="800px" Height="500px"
            DataSourceID="LinqDataSource1">
            <PlotArea>
                <Series>
                    <telerik:ColumnSeries DataFieldY="UnitsInStock" Name="Units In Stock">
                        <TooltipsAppearance Visible="false"></TooltipsAppearance>
                    </telerik:ColumnSeries>
                    <telerik:ColumnSeries DataFieldY="UnitsOnOrder" Name="Units On Order">
                        <TooltipsAppearance Visible="false"></TooltipsAppearance>
                    </telerik:ColumnSeries>
                </Series>
                <XAxis DataLabelsField="ProductName">
                    <LabelsAppearance></LabelsAppearance>
                    <MajorGridLines Visible="false"></MajorGridLines>
                    <MinorGridLines Visible="false"></MinorGridLines>
                </XAxis>
                <YAxis>
                    <TitleAppearance Text="Units"></TitleAppearance>
                    <MinorGridLines Visible="false"></MinorGridLines>
                </YAxis>
            </PlotArea>
            <ChartTitle Text="Products Balance">
            </ChartTitle>
        </telerik:RadHtmlChart>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance