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