This is a migrated thread and some comments may be shown as answers.

Databinding silverlight gauge control in existing asp.net page

1 Answer 62 Views
Gauge
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 02 Mar 2011, 08:56 PM
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
 

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 04 Mar 2011, 03:54 PM
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!
Tags
Gauge
Asked by
Scott
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or