Databinding silverlight gauge control in existing asp.net page

2 posts, 0 answers
  1. Scott
    Scott avatar
    6 posts
    Member since:
    Feb 2011

    Posted 02 Mar 2011 Link to this post

    Hello,

    I am new to silverlight....our requirements are for the fancy charts/gauges available in the silverlight rad controls product.  The problem is that we need to implement these silverlight charts/gages into an existing asp.net page.

    I have the gauge/chart showing in the aspx page but I am not sure what the best method is to bind data from a sql dataset/datatable to a chart and a gauge within an existing aspx page.

    Can someone provide some direction for me on how to achieve this requirement of databinding data from a sql dataset/datatable to a chart and a gauge control...( I assume the process will be almost identical for each)...

    Thanks in advance,
    Scott
     
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 04 Mar 2011 Link to this post

    Hi Scott,

    You can pass parameters to the Silverlight control using the user-defined initialization parameters for Silverlight Plug-in Object. The sample code below passes the gauge value to the Silverlight user control.
    Copy Code
    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
      <param name="initparams" value="gaugeValue=25"/>
      <param name="source" value="ClientBin/RadControlsSilverlightApp1.xap"/>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="4.0.50826.0" />
      <param name="autoUpgrade" value="true" />
      <param name="onload" value="pluginLoaded" />
      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
          <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
      </a>
    </object>
    Copy Code
    <UserControl x:Class="RadControlsSilverlightApp1.MainPage"
        mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
        <Grid x:Name="LayoutRoot">
            <telerik:RadGauge Height="200" Width="200">
                <telerik:RadialGauge>
                    <telerik:RadialScale>
                        <telerik:IndicatorList>
                            <telerik:Needle Name="Needle1" />
                        </telerik:IndicatorList>
                    </telerik:RadialScale>
                </telerik:RadialGauge>
            </telerik:RadGauge>
        </Grid>
    </UserControl>
    Copy Code
    using System.Globalization;
    using System.Windows;
    using System.Windows.Controls;
      
    namespace RadControlsSilverlightApp1
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
      
                string stringValue = Application.Current.Host.InitParams["gaugeValue"];
                double value = double.Parse(stringValue, CultureInfo.InvariantCulture);
      
                this.Needle1.Value = value;
            }
        }
    }

    For more information please take a look to the following articles:
    http://msdn.microsoft.com/en-us/library/cc838255(v=vs.95).aspx
    http://msdn.microsoft.com/en-us/library/cc645076(v=vs.95).aspx

    Kind regards,
    Andrey Murzov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. DevCraft banner
Back to Top