473,399 Members | 4,192 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,399 software developers and data experts.

can't add event handler :(

Hi,
I've got a datagrid with template column that contains a dropdownlist.
To add a event handler to each dropdown's in the grid I do that:

For Each dgi As DataGridItem In GridView2.Items
AddHandler CType(dgi.FindControl("GroupQueries"),
DropDownList).SelectedIndexChanged, AddressOf somefunction
Next

The control GroupQueries is found because I use the same technique to
bind the dropdown to a datasource. However when I run the app,
somefuntion is not called :(

here's the code of somefunction, although I doubt the problem comes
from here since it's not event called:

Public Sub somefunction(ByVal sender As Object, ByVal e As
System.EventArgs)
MsgBox("test")
End Sub

Can you help?
thanx

Feb 28 '06 #1
2 1123

Hi,
Why don't you bind the event handler in the ASPX markup like this (this
is not binding to event handler but you can do the same by using
onSelectedIndexChanged='somefunction')
<EditItemTemplate>
<asp:DropDownList runat="server"
SelectedIndex='<%#
GetStateIndex(Container.DataItem("state")) %>'
id="edit_State">
<asp:ListItem>CA</asp:ListItem>
<asp:ListItem>IN</asp:ListItem>
<asp:ListItem>KS</asp:ListItem>
<asp:ListItem>MD</asp:ListItem>
<asp:ListItem>MI</asp:ListItem>
<asp:ListItem>OR</asp:ListItem>
<asp:ListItem>TN</asp:ListItem>
<asp:ListItem>UT</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
Best regards,
Mohamed Sharaf
MEA Developer Support Center
ITWorx on behalf Microsoft EMEA GTSC

Feb 28 '06 #2
Sorry, I don't understand the way you do it. My dropdownlist is created
and filled dynamically. I doubt I can use the code above :(

Feb 28 '06 #3

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

Similar topics

5
by: Just Me | last post by:
Given a button name Btn_5 and Index=5 I want to do something like dim zz as string = Btn_??Index??.Text or given an array of buttons, do:
3
by: Beth | last post by:
in the following: this.ExitButton.Click += new System.EventHandler(this.ExitButton_Click); if I saw an equation, such as y +=x; then y = y+x. But what is the meaning in the event handler. I...
4
by: mflll | last post by:
I am looking into the different techniques of handling arrays of edit boxes in Java Script. The first program below works fine. However, are there better ways of doing this, where the person...
5
by: Charles Bazi | last post by:
Hi, I have a base UserControl named UserControlEx. I have created an event, and a dummy handler. Then I create several UCs with UserControlEx base. Some of those have a handler for my custom...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.