954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

SelectedIndexChanged not firing for dropdownlist

For some reason, selectedindexChanged vb.net code is no longer firing. autopostback and enable viewstate are sill true. Enabled is set to true in code behind. Using VS2008.

Any idea on what can cause this?

Thanks,
Randy

<asp:DropDownList id="ddlEmpName2" 
style="Z-INDEX: 138; LEFT: 192px; POSITION: absolute; TOP: 32px" runat="server" Width="152px" ForeColor="DarkBlue" DataValueField="EmployeeId" DataTextField="EmpLastFirst" DataSource="<%# dvEmpActiveList %>" 
Font-Size="X-Small" AutoPostBack="True" Enabled="False" 
AppendDataBoundItems="True" 
<asp:ListItem Selected="false" Text="Select" Value="0"></asp:ListItem>
</asp:DropDownList>
blackbr
Light Poster
25 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

Whats your code for capturing the change on the dropdown?

ninjaimp
Junior Poster
130 posts since Apr 2008
Reputation Points: 22
Solved Threads: 9
 

Thanks for the quick response,ninjaimp.
The session variable was set up to try to hold the info for the update, but the method does NOT fire

Public Sub ddlEmpName2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlEmpName2.SelectedIndexChanged
SelectedEmpId = ddlEmpName2.SelectedValue
Session("ddlEmpName2Session") = ddlEmpName2 '[4-29-2009]
lblOrgNameShort_DataBinding(Me, e)
SetActiveOrg(drOrg)
End Sub

blackbr
Light Poster
25 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

Hi Randy

There is no event selected in the HTML - runat Server is good but what sub are you going to call.

I think you have probably copied this control from another page - been there done it. Try double clicking the control and you should be fine.

tonym001
Newbie Poster
11 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

Hi Randy

There is no event selected in the HTML - runat Server is good but what sub are you going to call.

I think you have probably copied this control from another page - been there done it. Try double clicking the control and you should be fine.

Tony,
This was existing logic. When I double-click on the control, it creates the selectedIndexChanged sub, but does NOT reference the sub in the aspx file -- I guess because it's using the default name.

I have another ddl on the page, and it works correctly, though it does NOT have autopostback set. It also does not mention the sub in the aspx.

I'm still open to suggestions...

blackbr
Light Poster
25 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

Copy the code for the control, delete the control, save all, close the project, open the project, add the control back in again, put the code back in (after clicking) and then try it again.

If that does not work you will have to recreate the page from scratch.

tonym001
Newbie Poster
11 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

PS - Otherwise you could be searching the net for days

tonym001
Newbie Poster
11 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

Great Dude tonym001, it worked by deleting and recreating event on double click. Really, one would have kept searching web without trying this simple trick.

mohant
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Please change your front end code to include this:

<asp:DropDownList id="ddlEmpName2" 
style="Z-INDEX: 138; LEFT: 192px; POSITION: absolute; TOP: 32px" runat="server" Width="152px" ForeColor="DarkBlue" DataValueField="EmployeeId" DataTextField="EmpLastFirst" DataSource="<%# dvEmpActiveList %>" 
Font-Size="X-Small" AutoPostBack="True" Enabled="False" 
AppendDataBoundItems="True" onselectedindexchanged="ddlEmpName2_SelectedIndexChanged" >
<asp:ListItem Selected="false" Text="Select" Value="0"></asp:ListItem>
</asp:DropDownList>


Your snippet at the top does not have both a closing bracket on your DDL opening code or a reference to the onselectedindexchanged event.

Hope that helps :) Please remember to mark as solved once the issue is resolved.

Lusiphur
Posting Shark
Team Colleague
966 posts since Jun 2010
Reputation Points: 207
Solved Threads: 127
 

Make sure that the AutoPostBack Property is set to True on your Dropdownlist control.

CodeGorilla
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You