-1
の質問を送ってください。答えはラジオボタン で質問を表示して送信してください。 私はクイズフォームを持っています。このようないくつかのクラスを作った:リストを送って、asp.net mvc
public class Question
{
public int Qid { get; set; }
public string Questionstext { get; set; }
public int selected { get; set; }
public List<Qitem> lst { get; set; }
}
public class Qitem
{
public int id { get; set; }
public string txt { get; set; }
}
、私はビューに質問のリストを送信します。
答えが「選択中に入れなければなりませんどのように私はそれを表示し、解答を提出することができ、List<Question> llst = new List<Question>
{
new Question
{
Qid = 1,
Questionstext = "is it true?",
lst = new List<Qitem>
{
new Qitem
{
txt = "yes",
id = 1
},
new Qitem
{
id = 2,
txt = "no"
}
}
},
new Question
{
Qid = 1,
Questionstext = "is it true 2?",
lst = new List<Qitem>
{
new Qitem
{
txt = "yes2",
id = 3
},
new Qitem
{
id = 4,
txt = "yes3"
}
}
}
};
return View(llst);
'質問のプロパティ。 私の問題はビューと特にラジオボタンです。
が含まれている場合ビューへの別のモデル –
@HimaanSingh、 'TempData'はビューにデータを送るのには適していませんし、OPがやっているように強く型付けされたモデルでは' ViewBag'を提案するのは実用的です –