public ActionResult Index() { //书本下拉框 List <Subject> subjects = student.selectSubjects(); SelectList list = new SelectList(subjects, "SubjectId", "SubjectName"); ViewBag.list = list; //班级下拉框 List <HomeWork.Model.Class> classResult = classBll.getAllClass(); SelectList list2 = new SelectList(classResult, "ClassId", "ClassName"); ViewBag.list2 = list2; return(View()); }
//查看加入了哪个方言集 private void refreshPanelStuClass() { panelIndex.Hide(); panelManageIndex.Hide(); panelLogin.Hide(); panelUserInfo.Hide(); panelExam.Hide(); panelStuClass.Show(); panelClass.Hide(); panelCheckUser.Hide(); for (int i = flowLayoutPanel2.Controls.Count - 1; i >= 0; i--) { Control con = flowLayoutPanel2.Controls[i]; if (con is Label || con is LinkLabel) { flowLayoutPanel2.Controls.RemoveAt(i); } } for (int i = flowLayoutPanel3.Controls.Count - 1; i >= 0; i--) { Control con = flowLayoutPanel3.Controls[i]; if (con is Label || con is LinkLabel) { flowLayoutPanel3.Controls.RemoveAt(i); } } DataTable dt = classes.getOwnClass(UserHelper.userID); DataTable dtall = classes.getAllClass(dt); for (int i = 0; i < dt.Rows.Count; i++) { Label label1 = new Label(); label1.Location = new Point(3, 0); label1.Size = new Size(200, 20); label1.Text = dt.Rows[i]["class"].ToString(); flowLayoutPanel3.Controls.Add(label1); LinkLabel linklabel1 = new LinkLabel(); linklabel1.AutoSize = true; linklabel1.Location = new Point(172, 0); linklabel1.Size = new Size(170, 20); linklabel1.Name = dt.Rows[i]["class_id"].ToString(); linklabel1.Click += new EventHandler(linklabelCancel_Click); linklabel1.Text = "退出"; flowLayoutPanel3.Controls.Add(linklabel1); LinkLabel linklabel2 = new LinkLabel(); linklabel2.AutoSize = true; linklabel2.Location = new Point(272, 0); linklabel2.Size = new Size(170, 20); linklabel2.Name = dt.Rows[i]["class_id"].ToString(); linklabel2.Click += delegate(Object o, EventArgs ee) { doSomething(linklabel2); }; linklabel2.Text = "查看考卷"; flowLayoutPanel3.Controls.Add(linklabel2); } for (int i = 0; i < dtall.Rows.Count; i++) { Label label2 = new Label(); label2.Location = new Point(3, 0); label2.Size = new Size(250, 20); label2.Text = dtall.Rows[i]["class"].ToString(); flowLayoutPanel2.Controls.Add(label2); LinkLabel linklabel2 = new LinkLabel(); linklabel2.AutoSize = true; linklabel2.Location = new Point(175, 0); linklabel2.Size = new Size(77, 20); linklabel2.Text = "加入"; linklabel2.Name = dtall.Rows[i]["class_id"].ToString(); linklabel2.Click += new EventHandler(linklabelEnter_Click); flowLayoutPanel2.Controls.Add(linklabel2); } }