我试图在后面的 C# 代码中选择 DropDownList 中的索引,但 SelectedIndexChanged 事件不会触发。正确的方法是什么?
DropDownListChapterTitles.SelectedIndex = 1;
protected void DropDownListChapterTitles_SelectedIndexChanged(object sender, EventArgs e)
{ }
检查您的标记,它应该看起来像这样
<asp:DropDownList runat="server" ID="DropDownListChapterTitles" AutoPostBack="True"
OnSelectedIndexChange="DropDownListChapterTitles_SelectedIndexChanged">
</asp:DropDownList>
我添加了OnSelectedIndexChange="DropDownListChapterTitles_SelectedIndexChanged"
DropDownListChapterTitles.SelectedIndex = 1;
// Call it yourself
DropDownListChapterTitles_SelectedIndexChanged(this, null);