0
我有一个ASP列表框。每当我在列表中选择一个新的项目,下面的函数被调用:ASP ListBox返回-1
protected void prevSubList_SelectedIndexChanged(object sender, EventArgs e)
{
// Get the currently selected item in the ListBox index
int index = prevSubList.SelectedIndex;
if (index < 0)
{
return;
}
//get the nominee for that index
Nominees currNominee = nominees[index];
populateFields(currNominee);
}
<td ID="previousSubmissions" align="left">
<asp:ListBox ID="prevSubList" runat="server" Height="16px" Width="263px"
Rows="1" onselectedindexchanged="prevSubList_SelectedIndexChanged"
AutoPostBack="True">
</asp:ListBox>
</td>
问题是int index = prevSubList.SelectedIndex;
始终计算为-1。在我的列表中有三个项目,比如说我选择第二个项目,我认为这个值是1,但是它是-1。任何想法为什么?
标记,请。 – Icarus
@lcarus已更新 – user489041
是否有可能在每次回传中重置值或清除列表? – Kobi