473,756 Members | 7,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
SelectedIndexCh anged 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 dropdownlistbox es 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 SelectedIndexCh anged 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.Sele ctedIndexChange d, AddressOf _
Me.dlstWindow_S electedIndexCha nged

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_Sele ctedIndexChange d(ByVal sender As Object, ByVal _
e As System.EventArg s)

Dim strCurrentID As String
Dim currentDropDown List As DropDownList = CType(sender, DropDownList)

strCurrentID = currentDropDown List.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 1092

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

Similar topics

1
7320
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 derive from the parent custom control and add some text boxes, labels, buttons etc...
4
2561
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 know exactly where the table will be located on the page until runtime. Before the form control table is added to the Placeholder, I'm adding a whole bunch of tables to the Placeholder. This is a flowchart program and I have multiple action boxes...
0
3188
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 properly done, but the events which should be triggered with the button.click method are not triggered in Word. I don't understand because it properly works in the 3 others host applications. If someone has an issue, I would be most grateful. Thanks...
16
1228
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 jLOOP = 0 And iLOOP = 0 Then lblDISPLAY(((iLOOP) * iMaxPeriods) + jLOOP) = New TextBox
5
2724
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 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...
7
1759
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 events do this for me, but my extended textbox doesn't get created by those wonderful form setup wizards. So, 1) Is there a way I can pick up these events without having to code for each control and without using custom extended controls, OR
3
2466
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 create a subscription to the Click event of the Button and another to the SelectedIndexChanged del dropDown.
5
6760
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 link buttons to stay wired up to their click events. I have what is basically a simply survey question generation page. The page first displays a few static fields and a dropdownlist of various options for the user to select. When the user...
1
1730
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 create the controls (for example a delete-button), add them to a placeholder, add eventhandlers, and the controls are displayed as expected. I click the button, the event fires as I wanted, I delete a record in the
0
10040
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9846
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.