Solved

ASP.net VB.net AddHandler to timers that are dynamically added

Posted on 2014-02-15
2
517 Views
Last Modified: 2014-02-15
Hi. The code below is used to add a number of GridViews and Timers to update panels that are then added to a Table. How do I add a tick event handler to each timer that runs certain code in VB.net


    Dim oGridView As New GridView
        oGridView.ID = "xChartGridView" & CStr(oChartGridViewID_Counter)
        Dim oTimer As New Timer
        oTimer.ID = "xTimer" & CStr(oChartGridViewID_Counter)
        oTimer.Interval = "5000"
        Dim dt As DataTable = SQL_Data_Table.GetSQLDataTable(oConnectionString, SQL)
        Dim pvt As New Pivot(dt)
        oGridView.DataSource = pvt.PivotData(RowFields, DataField, oAggregate, ColumnFields)
        oGridView.DataBind()
      up.ContentTemplateContainer.Controls.Add(oGridView)
        up.ContentTemplateContainer.Controls.Add(oTimer)
        T.Rows(0).Cells(oColumn).Controls.Add(up)
        T.Rows(0).Cells(oColumn).Controls.Add(oGridView)
0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
ChloesDad earned 500 total points
ID: 39861900
You should be able to add a handler manually after creating the timer

   AddHandler oTimer.Tick, AddressOf oTimer_Tick

You may also need to have the timer created as a private variable in the form, as if its created with a local variable in a subroutine then at the end of the subroutine it will no longer be in scope and hence may not trigger.

eg Private with events oTimer as Timer

Then create the timer and the handler when you need them.

You should also remove the handler when you no longer need it

RemoveHandler oTimer.Tick, AddressOf oTimer_Tick
0
 

Author Closing Comment

by:murbro
ID: 39862355
Thanks
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question