We help IT Professionals succeed at work.

Dropdownlist Event not Triggering

Dovberman
Dovberman asked
on
I have a dropdown list that is sometimes populated by only one row.
I need to initialize a procedure by simply clicking on the single row.
OnSelectedIndexChanged does not work because the index is not changed.
OnSelectedIndexChanged does work when there are mulltiple rows.

Is there a way to trigger a procedure when there is only one row?

-----
<asp:DropDownList ID="ddlTopics" runat="server"
                    DataTextField="TopicDescr" DataValueField="TopicID"
                    Width="320px"
                    OnSelectedIndexChanged="ddlTopicsSelected_Click"
                    AutoPostBack="true">
                </asp:DropDownList>
Comment
Watch Question

You need to a default value to the DropDownList, use below code
ddlTopics.Items.Insert(0, new ListItem("Select Option", "-1"));
ddlTopics.SelectedIndex = 0;

This way user always have to select a value to populate the next dropdownlist

Author

Commented:
Thanks. This works. That explains why the first row of data lists I have seen on other sites is "Select a Value".

Explore More ContentExplore courses, solutions, and other research materials related to this topic.