Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2006, 02:57 AM
Registered User
 
Join Date: Feb 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default OnSelectedIndexChanged event not firing

Hi, I've been trying to get the OnSelectedIndexChanged event to fire, and it just won't.

In my asp code, i have this wrapped around my repeater (pseudo code snippet):

<ASP:Repeater blahh blah
<ASP:ItemTemplate>
<asp:DropDownList ID="roleDropList" DataValueField="RoleType"
   DataTextField="RoleType"
   DataSource= blah blah
   SelectedIndex= blah blah
   Visible="true"
   AutoPostBack="True"
   OnSelectedIndexChanged="DropDown_SelectedIndexChan ged"
   runat="server">
</asp:DropDownList>


ok.. so i've added the OnSelectedIndexChanged attribute to the dropdownlist, and specified the function DropDown_SelectedIndexChanged that's gonna get called everytime the dropdownlist menu selection changes right?


now, in my C# code in the .cs file i have this:

protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)
{
   Response.Write("Test Test Test");
}

I made it do a response.write just to see if the event fires. But nothing happens.

What else must i do to handle the events properly??

Thanks in advance!

 
Old February 20th, 2006, 01:01 PM
Registered User
 
Join Date: Feb 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've been doing some google searching on this problem, and i found this:
http://community.sgdotnet.org/blogs/.../13/15866.aspx

so basically i have to change my SelectedIndexChanged method to be public. and so i did that and tried to change the values in my dropdownlist, but the event still doesnt fire!

Can anyone help pls? Thanks in advance!

 
Old February 20th, 2006, 07:34 PM
Registered User
 
Join Date: Feb 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok.. i've answered my own question - in the Page_Load function, i did not wrap my initialization code inside a "if (!Page.IsPostBack)". So i was doing DataBind() everytime there was a postback - that messed up the firing of events.






Similar Threads
Thread Thread Starter Forum Replies Last Post
selectedindexchanged event not firing kaliaparijat ASP.NET 2.0 Professional 1 June 5th, 2008 08:58 AM
Event Firing tobriain C# 1 June 12th, 2007 08:19 AM
Custom event not firing flegel ASP.NET 2.0 Professional 0 February 23rd, 2007 06:31 AM
onSelectedIndexChanged event not firing??? MTLedari ASP.NET 2.0 Basics 5 December 19th, 2006 10:35 AM
catching the OnSelectedIndexChanged event Aaron Edwards Classic ASP Professional 1 October 5th, 2005 02:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.