Hello Telerik and Everyone Else!
I've tried very hard to look for a similar question that has already been answered but unfortunately I couldn't find one. So please bear with me.
As you know there is demo about ajaxifying the timer here:
http://demos.telerik.com/aspnet-ajax/ajax/examples/common/ajaxifytimer/defaultvb.aspx
This demo updates the whole RadGrid every interval of the timer.
What if instead of updating the whole RadGrid every interval of the timer, each of the datagrid row gets updated at different times - say the 1st row get's updated every 5 seconds, the 2nd row at 10 seconds, the 3rd row at 8 seconds, the 4th row at 30 seconds, and so on and so forth.
I guess what I want is that each datagrid row will have its own separate dynamically created timer running at different intervals. How can RadAjaxManager handle that kind of a scenario? Below are some code snippets of my failed attempt:
Thanks in advance!
I've tried very hard to look for a similar question that has already been answered but unfortunately I couldn't find one. So please bear with me.
As you know there is demo about ajaxifying the timer here:
http://demos.telerik.com/aspnet-ajax/ajax/examples/common/ajaxifytimer/defaultvb.aspx
This demo updates the whole RadGrid every interval of the timer.
What if instead of updating the whole RadGrid every interval of the timer, each of the datagrid row gets updated at different times - say the 1st row get's updated every 5 seconds, the 2nd row at 10 seconds, the 3rd row at 8 seconds, the 4th row at 30 seconds, and so on and so forth.
I guess what I want is that each datagrid row will have its own separate dynamically created timer running at different intervals. How can RadAjaxManager handle that kind of a scenario? Below are some code snippets of my failed attempt:
Public Class TCSTimer |
Inherits System.Timers.Timer |
Private mstrTag As Object |
Private mstrName As String |
Public Property Tag() As Object |
Get |
Return mstrTag |
End Get |
Set(ByVal value As Object) |
mstrTag = value |
End Set |
End Property |
Public Property Name() As String |
Get |
Return mstrName |
End Get |
Set(ByVal value As String) |
mstrName = value |
End Set |
End Property |
Public Sub New() |
MyBase.New() |
End Sub |
Public Sub New(ByRef sTag As Object, ByVal sName As String) |
mstrTag = sTag |
mstrName = sName |
End Sub |
End Class |
Partial Class _Default |
Inherits System.Web.UI.Page |
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound |
If TypeOf e.Item Is GridDataItem Then |
Dim dataItem As GridDataItem = CType(e.Item, GridDataItem) |
Dim item As GridDataItem = TryCast(e.Item, GridDataItem) |
Dim hlLink As HyperLink = item.FindControl("hlFPP") |
hlLink.NavigateUrl = "Default.aspx?panel=SubGrid&f=" & dataItem("FPP").Text.Split("-")(0).Trim & "&prog=" & dataItem("FPP").Text.Split("-")(1).Trim & _ |
"&prod=" & dataItem("FPP").Text.Split("-")(2).Trim & "&status=" & dataItem("Status").Text & _ |
"&message=" & dataItem("Message").Text |
hlLink.Text = dataItem("FPP").Text |
Dim lblTC As Label = item.FindControl("lblTC") |
lblTC.Text = Now().ToLongTimeString |
Dim lblCtr As Label = item.FindControl("lblCtr") |
lblCtr.Text = Now().ToLongTimeString |
If "/WP/".Contains("/" & dataItem("Status").Text.Trim.ToUpper & "/") Then |
item.BackColor = Color.DarkRed |
item.ForeColor = Color.Yellow |
hlLink.ForeColor = Color.White |
End If |
If "/B/M/".Contains("/" & dataItem("Status").Text.Trim.ToUpper & "/") Then |
item.BackColor = Color.Yellow |
item.ForeColor = Color.Blue |
End If |
Dim tmrGridTimer As TCSTimer = New TCSTimer(dataItem, hlLink.Text) |
tmrGridTimer.Interval = 1000 |
AddHandler tmrGridTimer.Elapsed, AddressOf tmrGridTimer_Elapsed |
Dim rajaxs As Telerik.Web.UI.AjaxSetting = New Telerik.Web.UI.AjaxSetting |
rajaxs.AjaxControlID = tmrGridTimer.Name |
Dim rajaxsupdctrl As Telerik.Web.UI.AjaxUpdatedControl = New Telerik.Web.UI.AjaxUpdatedControl |
rajaxsupdctrl.ControlID = "RadGrid1" |
rajaxs.UpdatedControls.Add(rajaxsupdctrl) |
rajaxsupdctrl.ControlID = lblTaktClock.ID |
rajaxs.UpdatedControls.Add(rajaxsupdctrl) |
rajaxsupdctrl.ControlID = lblCounter.ID |
rajaxs.UpdatedControls.Add(rajaxsupdctrl) |
rajaxsupdctrl.LoadingPanelID = "LoadingPanel1" |
rajaxs.UpdatedControls.Add(rajaxsupdctrl) |
RadAjaxManager1.AjaxSettings.Add(rajaxs) |
tmrGridTimer.Start() |
End If |
End Sub |
Public Sub tmrGridTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) |
Dim itmTC As Label = CType(CType(sender, TCSTimer).Tag, GridDataItem).FindControl("lblTC") |
Dim itmCtr As Label = CType(CType(sender, TCSTimer).Tag, GridDataItem).FindControl("lblCtr") |
Dim r As New Random() |
Dim t1, a1 As Integer |
t1 = r.Next(1, 100) |
a1 = r.Next(1, 100) |
itmTC.Text = t1 |
itmCtr.Text = a1 |
t1 = Nothing |
a1 = Nothing |
End Sub |
End Class |
Thanks in advance!