I'm using vb.net: I have a sub (BuildMyGauge) in code behind that dynamically creates circular gauges depending on rows from DataTable [If datatable returns 3 rows the Sub will build 3 Circular Gauges]. The gauge properties and an initial Pointer Value is also set in this sub (BuildMyGauge). At Runtime, each circular gauge is given a unique ID, I also use a timer to continuously update the Pointer Value.
I use the findControl method in the timer event to find the Gauge Controls and update the pointer values. The timer event and code in the timer event runs....but it does not update the controls on the asp page.
For now i just want to update the first control that is created and its ID is always CircularGauge0
*******************************************************************************************************************************************************
Partial Class live_mote
Inherits System.Web.UI.Page
Private LiveMoteGaugeArray As New CircularGauge()
Private msqlDataTable As New DataTable
Private intControlNumber As Integer
********************************************************************************************************************************************************
Private Sub BuildMyCircularGauge()
msqlDataTable = generalDAL.GetSensorConfiguration
' 'This sets up each gauge for each registered sensor on the mote
For Each Row As DataRow In msqlDataTable.Rows
With LiveMoteGaugeArray
.AutoFormat = GaugeSkins.Midnight
.ID = "CircularGauge" + Convert.ToString(intControlNumber)
' .Radius = 70
' .Height = Unit.Pixel(200)
' .Width = Unit.Pixel(200)
End With
Dim GaugeScale As New CircularScale()
With GaugeScale
.Minimum = 0
.Maximum = 100
.StartAngle = 115
.SweepAngle = 315
.MinorIntervalValue = 5
.ScaleBarSize = 10
.ScaleDirection = ScaleDirection.Clockwise
End With
LiveMoteGaugeArray.Scales.Add(GaugeScale)
Dim GaugePointer1 As New CircularPointer()
With GaugePointer1
.BackNeedleLength = 10
.NeedleStyle = NeedleStyle.Triangle
.PointerNeedleType = PointerNeedleType.Needle
.PointerPlacement = ScalePlacement.Near
'This gets the latest value from the database table and sets value on the gauge
If Convert.ToInt16(msqlDataTable.Rows(intControlNumber).Item(0).ToString) = 2 Then
.Value = realtimeDAL
ElseIf Convert.ToInt16(msqlDataTable.Rows(intControlNumber).Item(0).ToString) = 3 Then
.Value = realtimeDAL
ElseIf Convert.ToInt16(msqlDataTable.Rows(intControlNumber).Item(0).ToString) = 4 Then
.Value = realtimeDAL
End If
End With
GaugeScale.Pointers.Add(GaugePointer1)
Dim GaugeTick1 As New CircularGaugeTick()
With GaugeTick1
.TickStyle = TickStyle.MajorInterval
.TickHeight = 10
End With
GaugeScale.Ticks.Add(GaugeTick1)
Dim GaugeTick2 As New CircularGaugeTick()
With GaugeTick2
.TickStyle = TickStyle.MinorInterval
.TickHeight = 5
End With
GaugeScale.Ticks.Add(GaugeTick1)
Dim GaugeLabel1 As New CircularGaugeLabel()
With GaugeLabel1
.LabelStyle = TickStyle.MajorInterval
.LabelPlacement = ScalePlacement.Near
.Font = New Syncfusion.Web.UI.WebControls.Gauge.Font("Arial", "12", FontStyle.Bold)
End With
GaugeScale.Labels.Add(GaugeLabel1)
Dim GaugeLabel2 As New CircularGaugeLabel()
With GaugeLabel2
.LabelStyle = TickStyle.MinorInterval
.LabelPlacement = ScalePlacement.Near
.Font = New Syncfusion.Web.UI.WebControls.Gauge.Font("Arial", "12", FontStyle.Bold)
End With
GaugeScale.Labels.Add(GaugeLabel2)
Me.Form.Controls.Add(LiveMoteGaugeArray)
intControlNumber = intControlNumber + 1
Next
End Sub
********************************************************************************************************************************
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
BuildMyCircularGauge()
End Sub
********************************************************************************************************************************
Protected Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim xxx As CircularGauge
xxx = Page.FindControl("CircularGauge0")
xxx.Scales(0).Pointers(0).Value = Convert.ToDouble("10")
End Sub
End Class
*****************************************************************************************************************************