コード例 #1
0
        protected void StudentDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            // THIS EVENT ISN'T CALLED AND I DON'T KNOW WHY

            string id = StudentDropDownList.SelectedItem.ToString();

            List <Student> students = dt.viewStudents();

            foreach (Student s in students)
            {
                if (s.StudentID.Trim() == id.Trim())
                {
                    StudentNameLabel.Text = s.StudentName;
                }
            }

            courses = dt.getEnrolmentsForStudent(id);

            foreach (Course c in courses)
            {
                CoursesListBox.Items.Add(c.CourseName);
                bill += c.Cost;
            }

            CostLabel.Text = "Cost is " + bill.ToString();

            StudentNameLabel.DataBind();
            CoursesListBox.DataBind();
            CostLabel.DataBind();
        }
コード例 #2
0
        protected void RegisterStudentButton_Click(object sender, EventArgs e)
        {
            string firstName     = FirstNameTextBox.Text;
            string lastName      = LastNameTextBox.Text;
            string facultyNumber = FacultyNumberTextBox.Text;
            string university    = UniversityDropDown.SelectedValue;
            string specialty     = SpecialtyDropDown.SelectedValue;

            int[]  selectedItemsIndex = CoursesListBox.GetSelectedIndices();
            string courses            = string.Empty;

            for (int i = 0; i < selectedItemsIndex.Length; i++)
            {
                courses += CoursesListBox.Items[selectedItemsIndex[i]] + "\n";
            }

            string registrationDetails = String.Format
                                             ("FirstName: {0}\nLastName: {1}\nFacultyNumber: {2}\nUniversity: {3}\nSpecialty: {4}\nCourses: {5}\n",
                                             firstName, lastName, facultyNumber, university, specialty, courses);

            FormSelectionContainer.Text = registrationDetails;
        }