我想把回传的学生的选课情况表显示出来,为何显示不出来,求大佬指点,代码如下:
这是gridview空间部分:
protected void Form1_Load(object sender, EventArgs e)
{
Student stuobj = new Student();
string StuNo = stuobj.StuNo;
StuChoiceLessonHandle obj = new StuChoiceLessonHandle();
obj.SetStuChoiceLessonName(StuNo);
List<StuLessonUI> scllist=obj.GetStuChoiceLessonNameList();
dataGridView1.DataSource = scllist;
}
这是写在StuChoiceLessonHandle 类中的部分:
public void SetStuChoiceLessonName(string StuNo)
{
//取得自己数据表相关的资讯,取的全部资料
SetStuChoiceLessonInfo();
List<StudentChoiceLessonRef> objList = GetStuChoiceLessonList();
//准备「课程」全部资料
LessonHandle objLessonHandle = new LessonHandle();
objLessonHandle.SetLessonInfo();
List<Lesson> objLessonList = objLessonHandle.GetLessonList();
//准备「学生」全部资料
StudentInfoHandle objStudentandle = new StudentInfoHandle();
objStudentandle.SetStudentInfo();
List<Student> objStudentList = objStudentandle.GetStudentList();
//准备「老师」全部资料
TeacherHandle objTeacherHandle = new TeacherHandle();
objTeacherHandle.SetTeacherInfo();
List<Teacher> objTeacherList = objTeacherHandle.GetTeacherList();
var result = from p in objList
join le in objLessonList on p.LessonID equals le.LessonID
join s in objStudentList on p.StuNo equals s.StuNo
join t in objTeacherList on le.TeacherID equals t.TeacherEmployeeID
where s.StuNo == StuNo //条件:找出一名学生的课程数据
select new StuLessonUI
{
StuName = s.StuName,
LessonName = le.LessonName,
TeacherName = t.TeacherName,
CRoom = s.CRoom,
//StuNo = s.StuNo
};
StuChoiceLessonNameList = result.ToList();
if (StuChoiceLessonNameList.Count > 0)
StuChoiceLessonNameObj = StuChoiceLessonNameList[0];
}
public List<StuLessonUI> GetStuChoiceLessonNameList()
{ return StuChoiceLessonNameList; }
相关分类