0
다음 코드가 있습니다.'testinstances'이름이 현재 컨텍스트에 없습니다.
오류는이 라인에 있습니다 if (testinstances == null)
이름의 testinstances은 현재 컨텍스트에 존재하지 않습니다.
이 오류의 원인은 무엇입니까?
public ActionResult Index(int? classRoomId, int? courseId, int? testTypeId)
{
var classRoom = cls.GetAll();
var course = cos.GetAll();
var testType = tst.GetAll();
ViewBag.ClassRoomID = new SelectList(classRoom, "ClassRoomID", "ClassRoomTitle");
ViewBag.CourseID = new SelectList(course, "CourseID", "Title");
ViewBag.TestTypeID = new SelectList(testType, "TestTypeID", "TestTypeDesc");
if (classRoomId == null || courseId == null || testTypeId == null)
{
var testinstances = tt.GetAll();
}
else
{
var testinstances = tt.GetAll().Where(t => t.TestTypeID == testTypeId &&
t.ClassRoomID == classRoomId &&
t.CourseID == courseId);
}
if (testinstances == null)
{
throw new ArgumentNullException("No Test Found.Do you want to create one?");
RedirectToAction("Create");
}
return View(testinstances.ToList());
}
감사 P.S.W.g 당신의 대답. 당신의 대답으로, 나는 testinstances를 선언했고 그것은 작동합니다. 당신은 A + –
@frank입니다. 그의 대답을 수락하십시오. – dcaswell