我在我的 aspx 页面中有这个:
<asp:ListBox ID="ListBoxDelete" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ListBoxDelete_SelectedIndexChanged1"></asp:ListBox>
后面的代码:
protected void Page_Load(object sender, EventArgs e){
ListBoxDelete.Items.Clear();
List<string> itens = new List<string>();
for(var item in itens){
ListBoxDelete.Items.Add(item);
}
}
protected void ListBoxDelete_SelectedIndexChanged1(object sender, EventArgs e){
int x = ListBoxDelete.SelectedIndex;
doSomething(x);
}
我的 SelectedIndex 不起作用...如果我没记错的话,该值始终为 -1。有什么问题?