473,513 Members | 13,099 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to add SelectedIndexChanged event from code behind

I have a DataGrid with only one TemplateColumn wich contains a DropDownList.
After I bind the DataGrid I fill the dropDownLists with values in
ItemDataBound. None of the DropDownLists contains the same values. Some of
these DropDownLists have AutoPostBack set to true, but I'm having trouble
adding the SelectedIndexChanged event to them. This is my code:
ddlParameterValue = dataGridItem.FindControl("ddlParameterValue")
ddlParameterValue.AutoPostBack = True
AddHandler ddlParameterValue.SelectedIndexChanged, New
System.EventHandler(AddressOf ddlParameterValue_SelectedIndexChanged)
Public Sub ddlParameterValue_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs)
....
End Sub

I put a brakepoint on the method, but it never gets called. The
AutoPostBack part works fine.

Any ideas?

Shawn
Nov 19 '05 #1
3 3723
About this
Public Sub ddlParameterValue_SelectedIndexChanged(ByVal sender As
Object,ByVal e As System.EventArgs) DDL.SelectedIndexChanged
Patrick

"Shawn" <bo********@hotmail.com> wrote in message
news:#W**************@TK2MSFTNGP09.phx.gbl...
I have a DataGrid with only one TemplateColumn wich contains a DropDownList. After I bind the DataGrid I fill the dropDownLists with values in
ItemDataBound. None of the DropDownLists contains the same values. Some of these DropDownLists have AutoPostBack set to true, but I'm having trouble
adding the SelectedIndexChanged event to them. This is my code:
ddlParameterValue = dataGridItem.FindControl("ddlParameterValue")
ddlParameterValue.AutoPostBack = True
AddHandler ddlParameterValue.SelectedIndexChanged, New
System.EventHandler(AddressOf ddlParameterValue_SelectedIndexChanged)
Public Sub ddlParameterValue_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs)
...
End Sub

I put a brakepoint on the method, but it never gets called. The
AutoPostBack part works fine.

Any ideas?

Shawn

Nov 19 '05 #2
Shawn wrote:
I have a DataGrid with only one TemplateColumn wich contains a DropDownList.
After I bind the DataGrid I fill the dropDownLists with values in
ItemDataBound. None of the DropDownLists contains the same values. Some of
these DropDownLists have AutoPostBack set to true, but I'm having trouble
adding the SelectedIndexChanged event to them. This is my code:
ddlParameterValue = dataGridItem.FindControl("ddlParameterValue")
ddlParameterValue.AutoPostBack = True
AddHandler ddlParameterValue.SelectedIndexChanged, New
System.EventHandler(AddressOf ddlParameterValue_SelectedIndexChanged)
Public Sub ddlParameterValue_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs)
...
End Sub

I put a brakepoint on the method, but it never gets called. The
AutoPostBack part works fine.

Any ideas?

Shawn


Hi Shawn,

1) When are you adding the event handler,
2) Are other events working?

Even if the control exists already on the page, I believe you'd have to
make sure you add the handler during each page request (i.e. not just
the first time inside a If Not IsPostback block)

Damien

Nov 19 '05 #3
You were right, I had to add the handler during each page request.
"Damien" <Da*******************@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Shawn wrote:
I have a DataGrid with only one TemplateColumn wich contains a DropDownList. After I bind the DataGrid I fill the dropDownLists with values in
ItemDataBound. None of the DropDownLists contains the same values. Some of these DropDownLists have AutoPostBack set to true, but I'm having trouble adding the SelectedIndexChanged event to them. This is my code:
ddlParameterValue = dataGridItem.FindControl("ddlParameterValue")
ddlParameterValue.AutoPostBack = True
AddHandler ddlParameterValue.SelectedIndexChanged, New
System.EventHandler(AddressOf ddlParameterValue_SelectedIndexChanged)
Public Sub ddlParameterValue_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
...
End Sub

I put a brakepoint on the method, but it never gets called. The
AutoPostBack part works fine.

Any ideas?

Shawn


Hi Shawn,

1) When are you adding the event handler,
2) Are other events working?

Even if the control exists already on the page, I believe you'd have to
make sure you add the handler during each page request (i.e. not just
the first time inside a If Not IsPostback block)

Damien

Nov 19 '05 #4

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

Similar topics

0
5401
by: PeacError | last post by:
Using Microsoft Visual Studio .NET 2003, Visual C# .NET 1.1: I apologize if this question has been addressed elsewhere, but I could not find a reference to it in the search engine for this...
2
16975
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
2
1405
by: Brent Burkart | last post by:
Has anyone experienced any problems with their selectedindexchanged not firing when there are user controls present on the page? I have 4 controls on a page and only once I remove all 4 does my...
1
8344
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
2
453
by: CW | last post by:
Yes, Autopostback is true, and it doesn't make an iota of difference at all. HTML snippet and code (behind) snippet is as below: <asp:dropdownlist id="ddlLoginType" runat="server" Width="163px"...
3
1629
by: Jim | last post by:
Hi All, Can someone tell me why the SelectedIndexChanged event does not fire? <form id="Form1" method="post" runat="server">
0
976
by: Chrysan | last post by:
I have a popup window, which consist of 2 combobox. The second combobox's(cboCube) item collection will change based on the first combobox's(cboDatabase) event(selectedindex_changed) is fired. And,...
9
3803
by: j_stus | last post by:
Hello there I was trying to find something about this on web but with no success. I am using code behind. Basically I am creating drop down list dynamically. Everything works but calling...
4
5238
by: lakepeir | last post by:
Hello, I have combobox with a selectedindexchanged method that seems to be called when starting the application, launching the form with the combobox and making a change in the drop down box of...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
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
7432
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...
1
7094
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
5677
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,...
0
4743
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...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
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 ...

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.