selectindexchanged上的asp.net列表框不';不要挑起事件 1. 2. 3. 4.

selectindexchanged上的asp.net列表框不';不要挑起事件 1. 2. 3. 4.,asp.net,Asp.net,更新面板中有列表框 但是,当我选择某个内容时,它不会触发事件我做错了什么?您必须设置为true(默认值为false): 您需要将AutoPostBack属性设置为True。然后只有回发发生,您选择的索引事件将触发 protected void Page_Load(Object sender, EventArgs e) { if(!IsPostBack) DataBindListBox(); } <asp:ListBox AutoPostBack="true"

更新面板中有列表框

但是,当我选择某个内容时,它不会触发事件我做错了什么?

您必须设置为
true
(默认值为
false
):


您需要将
AutoPostBack
属性设置为True。然后只有回发发生,您选择的索引事件将触发

protected void Page_Load(Object sender, EventArgs e)
{ 
    if(!IsPostBack)
        DataBindListBox();
}

<asp:ListBox AutoPostBack="true" ID="list1" runat="server" Height="200" Style=" margin: 0"   OnSelectedIndexChanged="list1_SelectedIndexChanged">
   ....
protected void Page_Load(Object sender, EventArgs e)
{ 
    if(!IsPostBack)
        DataBindListBox();
}
<asp:ListBox AutoPostBack="true" ID="yourLIst" runat="server" Height="200" Style=" margin: 0"   OnSelectedIndexChanged="yourLIst_SelectedIndexChanged">