473,396 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Add events to array of controls created at runtime

Hi all,

I've got a web form that I've written code to create an array of
DropDownList controls on the page depending on how many records are pulled
back. The code to create the controls is working fine but now I need to add
events to the newly created DropDownList controls. I need to add the
SelectedIndexChanged event and I'm having a hard time getting the code to add
events to the controls since the names (IDs) are varied to include the record
row number like "name & (int)".

I've seen examples on other web-sites which have either syntax errors and/or
so do not compile on my pc. So my question is this...

If I have a group of dropdownlistboxes named dlstDropDown and I have changed
the ID of the controls before I add the control to my page to include an
index so they would be dlstDropDown0, dlstDropDown1, dlstDropDown2, etc...
How do I add a SelectedIndexChanged event to each of them? And/Or how would
I go about creating a generic private sub to capture this event?

What I've tried so far with no success is:

'before I add the control to the page
AddHandler dlstWindow.SelectedIndexChanged, AddressOf _
Me.dlstWindow_SelectedIndexChanged

It looks like the event either doesn't fire or isn't in the correct
AddressOf. This is the sub I've been playing with:

Private Sub dlstWindow_SelectedIndexChanged(ByVal sender As Object, ByVal _
e As System.EventArgs)

Dim strCurrentID As String
Dim currentDropDownList As DropDownList = CType(sender, DropDownList)

strCurrentID = currentDropDownList.ID

End Sub

I'm using 2003 (haven't migrated to 2005 yet). Any help would be greatly
appreciated. I've already burned an entire day on this and am working on
burning another one. :(

thanks in advance,
Steve.
Feb 1 '06 #1
0 1073

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mark | last post by:
Hi, I'm writing user controls with custom events. I have a parent custom event that exposes some abstract methods and some custom events. I have also created some new user controls that...
4
by: blue | last post by:
I have a drop-down list, a radio button list and a submit button. I'm adding these controls to a table and I'm adding the table to a Placeholder. I'm adding it to the Placeholder because I don't...
0
by: maitrepoy | last post by:
I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003. This addin consists in adding 2 new Buttons in the "File" Menu of office. This is...
16
by: Tym | last post by:
I have a piece of code thus: For iLOOP = 0 To iNoDays - 1 For jLOOP = 0 To iMaxPeriods - 1 iX = 10 + (iLOOP * (dCellWidth + 10)) iY = 10 + (jLOOP * (dCellHeight + 10)) + Me.Size.Height / 4 If...
5
by: Steve Moreno | last post by:
Hi all, I've got a web form that I've written code to create an array of DropDownList controls on the page depending on how many records are pulled back. The code to create the controls is...
7
by: Bruce HS | last post by:
I'd like to call my ancestor Validation Function every time any control on a Win Form generates a Validating or Validated event. I'm using VB. I've extended Textbox, for instance, to have its...
3
by: Jose Fernandez | last post by:
Hello. I would like to know how could i get all the subscriptions that my form has with the events of their controls. For example. I have a form with a textbox, a button and a dropdown. I...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
1
by: Klaus Jensen | last post by:
Subject: Handling events of controls created at runtime I need to render some buttons at runtime based on a database, tie events to them, and handle the events when they fire. In Page_Load I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.