Web Development & Execution
David Addison
by David Addison
share this
« Back to the Blog

Asp:DropDownList does not fire OnSelectedIndexChanged event in an Asp:Repeater

Asp:DropDownList does not fire OnSelectedIndexChanged event in an Asp:Repeater

It may be fairly easy to create dynamically generated drop down lists in repeaters, however how do you retrieve the data? This brief post will look at how to get data from using the OnSelectedIndexChanged handler for the DropDownList (DDL) control. The OnSelectedIndexChanged event handler is supposed to fire when a user selects a new item in the DDL, but without adding a few other attribrutes to the control it will not fire when selected. Here are the basic steps:

  • Create a protected DataSet variable in your codebehind for storing the data that you want to populate the DDL with.
  • Create a method in the codebehind for handling the OnSelectedIndexChanged event.
  • Set the datasource of the DDL to the protected Dataset.
  • Set the DDL AutoPostBack attribute to true.
  • Set the DDL OnSelectedIndexChanged handler to the method you created in the codebehind.
  • Set EnableViewState to false for the DDL, and the Repeater.

The last step is the one that will hang you up. Without setting the EnabledViewState attribute to false, the method for OnSelectedIndexChanged is never called. Here is some sample code relating to a categorization system:


                    <table border="0" cellspacing="4" cellpadding="4">
                        <td><%# DataBinder.Eval(Container.DataItem, "category") %></td>
                            DataSource='<%# this.groups %>'



    protected void categorySelect_IndexChanged(object sender, EventArgs e)
        DropDownList ddl = sender as DropDownList;
        if (ddl != null)


Thank you for contacting us!

We'll be in touch!

Back Home ×