-1
我是新的Web,真的卡住了。我需要使用ASP.NET和Entity Framework來製作QuizSystem。我第一次使用DATABSE,我有這樣的表ASP.NET實體框架製作測驗
而且
我努力使創建視圖的問題,但問題是問使用一些已經取得變量作爲答案我只需要從下拉列表中選擇它。
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "Text,AnswerID,ChapterID")] QuestionVariant questionVariant)
{
if (ModelState.IsValid)
{
db.QuestionVariants.Add(questionVariant);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.ChapterID = new SelectList(db.Chapters, "ChapterID", "ChapterName", questionVariant.ChapterID);
ViewBag.AnswerID = new SelectList(db.Variants, "VariantID", "Text", questionVariant.AnswerID);
return View(questionVariant);
}
是否可以在同一視圖中創建問題和變體?如果是這樣,控制器和視圖應該如何顯示?不要只把-1,幫助我一些建議或任何有助於解決這個問題。
QuestionVariants是指問題的答案? – Nico
@Nico是的問題可能的答案 –
你在問什麼?當然,你可以把它們放在同一個視圖中......你已經展示了你的視圖發送到的POST方法處理程序? – Milney