public ActionResult CCEEvaluationGetStudentMarks(int BranchID, int ClassID, int BranchSectionID)
{
List<object> subjectData = BindSubjects(BranchID, ClassID, BranchSectionID);
ViewBag.subjectData = subjectData.ToList();
}
public List<object> BindSubjects(int BranchID, int ClassID, int BranchSectionID)
{
// return db.GetAcademicSubjectDetailsforDEO(ClassID, dts.AcademicYearID).ToList();
try
{
dts = GetLogOnSessionModel(); dts.PageName = "/" + this.GetType().Name + "/" + System.Reflection.MethodBase.GetCurrentMethod().Name;
List<object> d = new List<object>();
if (dts.AccessLevelID == 5)
{
// staff
if (dts.IsClassTeacher)
{
// classteacher
List<GetAcademicStaffSubjectDetailsByClassTeacher_Result> data = db.GetAcademicStaffSubjectDetailsByClassTeacher(dts.PersonalID, BranchID, dts.AcademicYearID, ClassID).ToList();
d = data.Cast<object>().ToList();
}
else
{
// ds = Sub.GetAcademicStaffSubjectDetails(int.Parse(ddlClass.SelectedValue), CoursesSession.Courses.AcademicYearID, StaffSession.Staff.StaffId, 1);
}
}
else
{
List<GetAcademicSubjectDetailsforDEO_Result> data = db.GetAcademicSubjectDetailsforDEO(ClassID, dts.AcademicYearID).ToList();
d = data.Cast<object>().ToList();
}
return d;
}
catch (Exception)
{
throw;
}
}
在C#中我使用不同的存储过程,所以我把它放在一个对象列表中并发送到视图,这样你怎么能绑定list<object>
:
@foreach (var subjectHeader in ViewBag.subjectData as List<object>)
{
<th>
@subjectHeader
</th>
}
我是razor的新手请帮助我如何绑定viewbag
而不使用只使用对象列表的类文件,如果有可能的话......?