0
ASP listBox가 있습니다. 나는이 목록에 새 항목을 선택할 때마다 다음과 같은 함수가 호출됩니다 : 문제는 int index = prevSubList.SelectedIndex;
입니다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>
는 항상 -1로 평가합니다. 내 목록에 세 가지 항목이 있습니다. 두 번째 항목을 선택하면 값이 1이지만 -1이라고 예상됩니다. 어떤 아이디어?
마크 업주세요. – Icarus
@lcarus updated – user489041
값을 다시 설정하거나 모든 포스트 백에서 목록을 지울 수 있습니까? – Kobi