我只是想将单选按钮列表的 SelectedIndex 放入 OnSelectedIndexChanged 事件的 int 数组中。我尝试了以下代码但不起作用:
我做了一个这样的数组:
int[] correctAnswers = { -1, -1, -1, -1, -1 }; and i tried this as well:
int[] correctAnswers = new int[100];
//SelectionChangeEvent
protected void rbAnswers_SelectedIndexChanged(object sender, EventArgs e)
{
int j = rbAnswers.SelectedIndex;
correctAnswers.SetValue(j, i); //or correctAnswers[i] = j;
}
我正在.Net 中制作一个在线测试系统。我正在更改标签中的问题和 RadioButtonList 中的答案。值来自数据库。我正在动态更改 RadioButtonList 但是如果我选择一个答案并单击下一个按钮,然后按上一个按钮返回,我的选择就会消失。所以为此我有一个逻辑是将选定的索引存储在一个 int 数组中,然后在下一个和上一个按钮调用该索引值并放入 RadioButtonList 的 SelectedIndex 中。所以请帮助我,我怎样才能在 OnSelectionChange 的 int 数组中获取这个选定的值?还有一个补充是我使 RadioButtonList 的 Post Back True。