0
當IAM裝盤,以填補例如中間表時,學生要添加coourse我有我的觀點一個DropDownList的seletec學生一個DropDownList的所有課程和在我看來DROPDOWNLIST所有學生如何設置atributes爲@ Html.DropDownList
table sample
{
id,
studentid,
courseid,
grade,
studentTeacher
}
我控制器
ViewBag.Student= new SelectList(db.Course.Where(c => c.StudentId== id), "StudentId","FullName");
ViewBag.CourseId = new SelectList(db.Course, "CourseId ", "Name");
ViewBag.StudentId = new SelectList(db.Student, "StudentId","FullName");
@Html.DropDownList("Student")
@Html.DropDownList("CourseId ")
@Html.DropDownList("StudentId ", string.Empty)
我得到一個錯誤它說沒有類型'IEnumerable'有關鍵'學生'的ViewData項目。
,所以我guees正在尋找一個關鍵StudentId,所以待會我怎麼能告訴DropDownList的看向從(學生),其鍵(StudentId)