DataSourceControls

The ShieldChart can be data bound to an SqlDataSource, LinqDataSource, EntityDataSource, ObjectDataSource, XmlDataSource. The following properties should be used to achieve this:

  • DataSourceID in the main tag sets the declarative datasource for the entire chart. In this case you do not need to set a datasource to the DataSource property of the chart.
  • DataFieldX, DataFieldY (DataFieldLow or DataFieldHigh for range series) for the series to point it to the desired column of the data table.
<shield:ShieldChart ID="ShieldChart1" Width="100%" Height="400px" runat="server"
    CssClass="chart" DataSourceID="SqlDataSource1">
    <DataSeries>
        <shield:ChartBarSeries DataFieldY="UnitsInStock">
        </shield:ChartBarSeries>
    </DataSeries>
</shield:ShieldChart>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ProductName], [UnitsInStock] FROM [Products] WHERE ([CategoryID] = 1)"></asp:SqlDataSource>

For more information see Bind to SqlDataSource example.

<shield:ShieldChart ID="ShieldChart2" Width="100%" Height="400px" runat="server"
    CssClass="chart" DataSourceID="LinqDataSource1">
    <DataSeries>
        <shield:ChartBarSeries DataFieldY="UnitsInStock">
        </shield:ChartBarSeries>
    </DataSeries>
</shield:ShieldChart>
<asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="NorthwindDataContext"
    TableName="Products">
</asp:LinqDataSource>

For more information see Bind to LinqDataSource example.

<shield:ShieldChart ID="ShieldChart3" Width="100%" Height="400px" runat="server"
    CssClass="chart" DataSourceID="EntityDataSource1">
    <DataSeries>
        <shield:ChartBarSeries DataFieldY="UnitsInStock">
        </shield:ChartBarSeries>
    </DataSeries>
</shield:ShieldChart>
<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=NorthwindEntities"
    DefaultContainerName="NorthwindEntities" CommandText="select p.ProductName, p.UnitsInStock from NorthwindEntities.Products as p where p.CategoryID = 1">
</asp:EntityDataSource>

For more information see Bind to EntityDataSource example.

<shield:ShieldChart ID="ShieldChart4" Width="100%" Height="400px" runat="server"
    CssClass="chart" DataSourceID="ObjectDataSource1">
    <DataSeries>
        <shield:ChartBarSeries DataFieldY="UnitsInStock">
        </shield:ChartBarSeries>
    </DataSeries>
</shield:ShieldChart>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="Product"
    SelectMethod="GetProducts"></asp:ObjectDataSource>

For more information see Bind to ObjectDataSource example.

<shield:ShieldChart ID="ShieldChart5" Width="100%" Height="400px" runat="server"
    CssClass="chart" DataSourceID="XmlDataSource1">
    <DataSeries>
        <shield:ChartBarSeries DataFieldY="UnitsInStock">
        </shield:ChartBarSeries>
    </DataSeries>
</shield:ShieldChart>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="ChartData.xml">
</asp:XmlDataSource>

For more information see Bind to XmlDataSource example.