protected void Page_Load(object sender, EventArgs e) { //获取所有班级 SqlConnection sqlConnection = SqlTools.Connection(); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("select * from classinfo", sqlConnection); DataSet dataSet = new DataSet(); sqlDataAdapter.Fill(dataSet); //所有班级绑定到班级下拉框 DropDownListClass.DataSource = dataSet; DropDownListClass.DataTextField = "name"; DropDownListClass.DataBind(); //获取所有系别 SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter("select * from dept", sqlConnection); DataSet dataSet1 = new DataSet(); sqlDataAdapter1.Fill(dataSet1); //所有系别绑定到系别下拉框 DropDownListDept.DataSource = dataSet1; DropDownListDept.DataTextField = "name"; DropDownListDept.DataBind(); sqlConnection.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //获取要编辑学生 string id = Request.QueryString["id"]; Student s = (Student)dao.getBody(id, 1); TextBoxID.Text = s.ID1; TextBoxName.Text = s.Name1; TextBoxPassword.Text = s.Password1; TextBoxBirth.Text = s.Birth1; TextBoxEmail.Text = s.Email1; TextBoxPhone.Text = s.Telephone1; TextBoxAddress.Text = s.Address1; TextBoxState.Text = s.State1; if (s.Sex1.Equals("女")) { RadioButtonSexFemale.Checked = true; } else { RadioButtonSexMale.Checked = true; } //获取所有班级 SqlConnection sqlConnection = SqlTools.Connection(); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("select * from classinfo", sqlConnection); DataSet dataSet = new DataSet(); sqlDataAdapter.Fill(dataSet); //所有班级绑定到班级下拉框 DropDownListClass.DataSource = dataSet; DropDownListClass.DataTextField = "name"; DropDownListClass.DataBind(); //下拉框选中该学生班级 DropDownListClass.SelectedValue = s.Class1; //获取所有系别 SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter("select * from dept", sqlConnection); DataSet dataSet1 = new DataSet(); sqlDataAdapter1.Fill(dataSet1); //所有系别绑定到系别下拉框 DropDownListDept.DataSource = dataSet1; DropDownListDept.DataTextField = "name"; DropDownListDept.DataBind(); //下拉框选中该学生系别 DropDownListDept.SelectedValue = s.Dept1; sqlConnection.Close(); } //不能改学号 TextBoxID.Enabled = false; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownListDept.DataSource = DAL.GetDepartments(); DropDownListDept.DataBind(); } }
protected void DropDownListInstOnSelectedIndexChanged(object sender, EventArgs e) { DropDownListDept.Items.Clear(); DropDownListDept.Items.Add(new ListItem("ALL", "ALL", true)); SqlDataSourceDept.SelectCommand = "select DeptId,DeptName from Dept_M where Institute_Id='" + DropDownListInst.SelectedValue + "'"; SqlDataSourceDept.DataBind(); DropDownListDept.DataBind(); if (DropDownListDept.Items.Count == 2) { DropDownListDept.Items.Remove("ALL"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownListDept.DataSource = DAL.GetDepartments(); DropDownListDept.DataBind(); DropDownListManager.DataSource = DAL.GetEmployeeIdAndName(); DropDownListManager.DataBind(); DropDownListManager.Items.Add(new ListItem("--select--", "0")); DropDownListManager.SelectedValue = "0"; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownListDept.DataSource = DAL.GetDepartments(); DropDownListDept.DataBind(); DropDownListManager.DataSource = DAL.GetEmployeeIdAndName(); DropDownListManager.DataBind(); RangeValidator2.MaximumValue = DateTime.Now.ToShortDateString(); RangeValidator2.MinimumValue = DateTime.Now.AddYears(-100).ToShortDateString(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //获取要编辑老师 string id = Request.QueryString["id"]; Teacher t = (Teacher)dao.getBody(id, 2); TextBoxID.Text = t.ID1; TextBoxName.Text = t.Name1; TextBoxPassword.Text = t.Password1; TextBoxBirth.Text = t.Birthday1; TextBoxEmail.Text = t.Email1; TextBoxPhone.Text = t.Telephone1; TextBoxAddress.Text = t.Address1; TextBoxState.Text = t.State1; TextBoxArriveDate.Text = t.ArriveDate1; if (t.Sex1.Equals("女")) { RadioButtonSexFemale.Checked = true; } else { RadioButtonSexMale.Checked = true; } //获取所有系别 SqlConnection sqlConnection = SqlTools.Connection(); SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter("select * from dept", sqlConnection); DataSet dataSet1 = new DataSet(); sqlDataAdapter1.Fill(dataSet1); //所有系别绑定到系别下拉框 DropDownListDept.DataSource = dataSet1; DropDownListDept.DataTextField = "name"; DropDownListDept.DataBind(); //下拉框选中该老师系别 DropDownListDept.SelectedValue = t.Department1; sqlConnection.Close(); } //不能改工号 TextBoxID.Enabled = false; }