473,671 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to add SelectedIndexCh anged 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 SelectedIndexCh anged event to them. This is my code:
ddlParameterVal ue = dataGridItem.Fi ndControl("ddlP arameterValue")
ddlParameterVal ue.AutoPostBack = True
AddHandler ddlParameterVal ue.SelectedInde xChanged, New
System.EventHan dler(AddressOf ddlParameterVal ue_SelectedInde xChanged)
Public Sub ddlParameterVal ue_SelectedInde xChanged(ByVal sender As Object,
ByVal e As System.EventArg s)
....
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 3742
About this
Public Sub ddlParameterVal ue_SelectedInde xChanged(ByVal sender As
Object,ByVal e As System.EventArg s) DDL.SelectedInd exChanged
Patrick

"Shawn" <bo********@hot mail.com> wrote in message
news:#W******** ******@TK2MSFTN GP09.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 SelectedIndexCh anged event to them. This is my code:
ddlParameterVal ue = dataGridItem.Fi ndControl("ddlP arameterValue")
ddlParameterVal ue.AutoPostBack = True
AddHandler ddlParameterVal ue.SelectedInde xChanged, New
System.EventHan dler(AddressOf ddlParameterVal ue_SelectedInde xChanged)
Public Sub ddlParameterVal ue_SelectedInde xChanged(ByVal sender As Object,
ByVal e As System.EventArg s)
...
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 SelectedIndexCh anged event to them. This is my code:
ddlParameterVal ue = dataGridItem.Fi ndControl("ddlP arameterValue")
ddlParameterVal ue.AutoPostBack = True
AddHandler ddlParameterVal ue.SelectedInde xChanged, New
System.EventHan dler(AddressOf ddlParameterVal ue_SelectedInde xChanged)
Public Sub ddlParameterVal ue_SelectedInde xChanged(ByVal sender As Object,
ByVal e As System.EventArg s)
...
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.goo glegroups.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 SelectedIndexCh anged event to them. This is my code:
ddlParameterVal ue = dataGridItem.Fi ndControl("ddlP arameterValue")
ddlParameterVal ue.AutoPostBack = True
AddHandler ddlParameterVal ue.SelectedInde xChanged, New
System.EventHan dler(AddressOf ddlParameterVal ue_SelectedInde xChanged)
Public Sub ddlParameterVal ue_SelectedInde xChanged(ByVal sender As Object, ByVal e As System.EventArg s)
...
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
5417
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 board. I have a form that contains a ListView and a GroupBox control. The GroupBox control itself contains several TextBox Controls. I have Validating and Validated event handlers set for the GroupBox control, and a SelectedIndexChanged event...
2
17006
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 the columns of the data grid contains a DropDownlist. I managed to create this datagrid control as follows.
2
1415
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 dropdownbox selectedindexchanged work. Any ideas?
1
8383
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 I want to do is to allow the user to click on the row that corresponds to the correct address, and have the code behind populate the form's Address1, Address2 etc. controls with the relevant data items. I put the code for this into the...
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" AutoPostBack="True"></asp:dropdownlist> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
3
1643
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
982
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, I do have write such code in code-behind as follow: Private Sub cboDatabase_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboDatabase.SelectedIndexChanged Dim strAdomdConnectionString As String Try
9
3809
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 SelectedIndexChanged event never fires up. I found some discussions regarding this problem, but couldn't find answer.... Here is my code. Protected WithEvents ddl As System.Web.UI.WebControls.DropDownList
4
5247
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 the combobox. Can anyone tell me why the method is called so often? I would only like the method executed when a user makes a change in the drop down box. Am I using the incorrect method. Thanks.
0
8476
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8393
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8917
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...
1
8598
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
8670
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...
0
7437
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4407
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2812
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
2051
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.