DropDownList不调用SelectedIndexChanged?

发布于 2024-12-12 06:49:56 字数 704 浏览 4 评论 0原文

我的下拉列表中有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱她像谁 2024-12-19 06:49:56

如果它对一个人有效,那么它也应该对每个人都有效;在选择时不会回发的一个实例是,如果该项目已经被选中,例如默认情况下 - 那么您需要选择其他内容,然后重新选择所述“默认”值。

否则的话,我看不出任何一个项目会受到歧视。

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.

不必在意 2024-12-19 06:49:56

原因可能是默认选择第一项。您可以尝试添加一个新项目并将其设置为第一个:

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

这样,当您选择案例 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:

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文