DropDownList doesn't call SelectedIndexChanged?

I have 7 items in my dropdown list like

<asp:DropDownList ID="DdlSortBy" runat="server" OnSelectedIndexChanged="DdlSortBy_SelectedIndexChanged"
    AutoPostBack="True">
    <asp:ListItem Value="0">Case 1</asp:ListItem>
    <asp:ListItem Value="1">Case 2</asp:ListItem>
    <asp:ListItem Value="2">Case 3</asp:ListItem>
    <asp:ListItem Value="3">Case 4</asp:ListItem>
    <asp:ListItem Value="4">Case 5</asp:ListItem>
    <asp:ListItem Value="5">Case 6</asp:ListItem>
    <asp:ListItem Value="6">Case 7</asp:ListItem>
</asp:DropDownList>

all items except Case 1 value 0 initiate selected index change event.

Any idea how to fix it?


If it is working for one then it should be working for each of them; an instance in which it won't postback upon selection would be if that item was already selected, say, by default - then you would need to select something else, then re-select said "default" value.

Otherwise, I can't see that any single item would be discriminated against.


The reason might be that the first item is selected by default. What you could try is to add a new item and set it to be the first:

 <asp:ListItem Value="-1">please select</asp:ListItem>

That way, when you select Case 1, it will fire the event.

链接地址: http://www.djcxy.com/p/67230.html

上一篇: SelectedIndexChanged的Radio列表在radgrid内部没有触发

下一篇: DropDownList不会调用SelectedIndexChanged?