can't add event handler :(

S

samuelberthelot

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
 
M

Mohamed Sharaf

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
 
S

samuelberthelot

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 :(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top