?
Solved

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

Posted on 2014-02-15
2
Medium Priority
?
520 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:Murray Brown
[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 2000 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:Murray Brown
ID: 39862355
Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

770 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