0

我试图在后面的 C# 代码中选择 DropDownList 中的索引,但 SelectedIndexChanged 事件不会触发。正确的方法是什么?

  DropDownListChapterTitles.SelectedIndex = 1;


  protected void DropDownListChapterTitles_SelectedIndexChanged(object sender, EventArgs e)
  { }
4

2 回答 2

0

检查您的标记,它应该看起来像这样

<asp:DropDownList runat="server" ID="DropDownListChapterTitles" AutoPostBack="True"
     OnSelectedIndexChange="DropDownListChapterTitles_SelectedIndexChanged">

</asp:DropDownList>

我添加了OnSelectedIndexChange="DropDownListChapterTitles_SelectedIndexChanged"

于 2012-10-06T15:03:06.897 回答
0
DropDownListChapterTitles.SelectedIndex = 1;
// Call it yourself
DropDownListChapterTitles_SelectedIndexChanged(this, null);
于 2012-10-06T14:36:38.053 回答