Subject: OnSelectedIndexChanged event not firing
Posted By: ethertt77 Post Date: 2/20/2006 1:57:40 AM
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_SelectedIndexChanged"
   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!

Reply By: ethertt77 Reply Date: 2/20/2006 12:01:18 PM
I've been doing some google searching on this problem, and i found this:
http://community.sgdotnet.org/blogs/triplez/archive/2005/05/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!

Reply By: ethertt77 Reply Date: 2/20/2006 6:34:46 PM
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.


Go to topic 39268

Return to index page 364
Return to index page 363
Return to index page 362
Return to index page 361
Return to index page 360
Return to index page 359
Return to index page 358
Return to index page 357
Return to index page 356
Return to index page 355