Default.aspx.cs
上传用户:xy99169
上传日期:2022-08-03
资源大小:139k
文件大小:2k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Configuration;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Collections;
- using System.Collections.Generic;
- public partial class _Default : System.Web.UI.Page
- {
- static ArrayList students = new ArrayList();
- static List <Student> students2=new List<Student>();
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- string[] classNames = new string[] { "08多1", "08多2", "09多1", "09多2" };
- drpClass.DataSource = classNames;
- drpClass.DataBind();
- Student st = new Student("083000001", "Mary", "08多1", "12345678");
- students2.Add(st);
- bindStudent();
- }
- }
- protected void bindStudent()
- {
- lbxStudentInfo.DataSource = students2;
- lbxStudentInfo.DataBind();
- }
- protected void btnAdd_Click(object sender, EventArgs e)
- {
- string id = txtID.Text;
- string name = txtName.Text;
- string classIn = drpClass.Text;
- string phone = txtPhone.Text;
- Student st = new Student(id,name,classIn,phone);
- if (st.IsValid)
- {
- students2.Add(st);
- bindStudent();
- }
- }
- protected void lbxStudentInfo_SelectedIndexChanged(object sender, EventArgs e)
- {
- int index = lbxStudentInfo.SelectedIndex;
- if (index >= 0 && index < students2.Count)
- {
- Student st = students2[index];
- labStudent.Text = "学号:" + st.StudentID + "<br/>";
- labStudent.Text += "姓名:" + st.StudentName + "<br/>";
- labStudent.Text += "所在班级:" + st.ClassIn + "<br/>";
- labStudent.Text += "联系电话:" + st.Phone + "<br/>";
- }
- }
- }