![](/img/trans.png)
[英]ASP.Net DropDownList OnSelectedIndexChange not firing
[英]ASP.net C# page, 2 DropDownList on page with 2 onSelectedIndexChange only the first one fires
<tr>
<td>
State:
</td>
<td>
<asp:DropDownList runat="server" ID="stateListBox" CssClass="ListBox" SelectionMode="Single"
DataTextField="stateorregion" DataValueField="stateorregion" AppendDataBoundItems="true"
OnSelectedIndexChanged="populateCourseListBox" AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Course:
</td>
<td>
<asp:DropDownList runat="server" ID="courseListBox" CssClass="ListBox" SelectionMode="Single"
DataTextField="courseName" DataValueField="course_id" AppendDataBoundItems="true"
OnSelectedIndexChange="onCourseSelectedIndexChange" AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
这2个DropDownList应该以相同的方式执行,populateCourseListBox被调用,而onCourseSelectedIndexChange没有被调用,没有编译器错误,没有运行时错误。 我在这里缺少明显的东西吗?
这个想法是,当我选择一个州时,我想填充该州的高尔夫球场,然后一旦选择了一个高尔夫球场,就希望能够选择一个发球区。 当我更改状态时,将填充课程表框,但是当我选择课程时,将调用page_load,仅此而已。
在课程DDL中将OnSelectedIndexChange
替换为OnSelectedIndexChanged
。 有一个拼写错误。
如果控件属性不是事件标识符,它将被视为自定义属性。 这就是为什么您没有任何错误的原因。 :)
而且,如果可以利用Ajax控制工具套件中的CascadingDropDown
控件,您会更好。 这可以帮助您级联选择多个下拉菜单。 看这个例子 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.