フォーム コレクションを使用して、質問[i] として予測的に名前が付けられたラジオ ボタンの値を取得するにはどうすればよいですか?
フォーム コレクション内
Questions[0].ObjectId
Questions[0].SelectedAnswer
Questions[1].ObjectId
Questions[1].SelectedAnswer
Questions[2].ObjectId
Questions[2].SelectedAnswer
3 - 13 ... etc...
Questions[14].ObjectId
Questions[14].SelectedAnswer
(a bunch of other stuff)
コントローラーで
[HttpPost]
public ActionResult PostResults(FormCollection form)
{
List<SelectedAnswer> selectedAnswers = new List<SelectedAnswer>();
for (int i = 0; i < 15; i++)
{
//this is the part that is not working...
selectedAnswers.Add(new SelectedAnswer() { questionId = form["Questions"][i].ObjectId; answerId = form["Questions"][i].SelectedAnswer}
}
//continue to do other stuff
}
私の最終的な目標は、選択した値をデータベースに保存することです。