DropDownList不调用SelectedIndexChanged?
我的下拉列表中有 7 个项目,就像
<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>
除案例 1 值 0 之外的所有项目一样,启动选定的索引更改事件。
知道如何修复它吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它对一个人有效,那么它也应该对每个人都有效;在选择时不会回发的一个实例是,如果该项目已经被选中,例如默认情况下 - 那么您需要选择其他内容,然后重新选择所述“默认”值。
否则的话,我看不出任何一个项目会受到歧视。
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.
原因可能是默认选择第一项。您可以尝试添加一个新项目并将其设置为第一个:
这样,当您选择案例 1 时,它将触发该事件。
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:
That way, when you select Case 1, it will fire the event.