Example #1
0
        /// <summary>
        /// Load the coordinated students for the audition  (do not load duets b/c they must be deleted by deleting the audition)
        /// If the student has several auditions for the event, the coordination will
        /// be removed for all auditions.
        /// </summary>
        protected void cboAudition_SelectedIndexChanged(object sender, EventArgs e)
        {
            int auditionId = -1;

            if (cboAudition.SelectedIndex > -1 && Int32.TryParse(cboAudition.SelectedValue, out auditionId))
            {
                DataTable table = DbInterfaceStudentAudition.GetUniqueAuditionCoordinates(auditionId);

                // Clear table
                while (tblCoordinates.Rows.Count > 1)
                {
                    tblCoordinates.Rows.RemoveAt(1);
                }

                for (int i = 0; i < table.Rows.Count; i++)
                {
                    TableRow  row                     = new TableRow();
                    TableCell chkBoxCell              = new TableCell();
                    TableCell studentIdCell           = new TableCell();
                    TableCell coordinateStudentIdCell = new TableCell();
                    TableCell coordinateLastNameCell  = new TableCell();
                    TableCell coordinateFirstNameCell = new TableCell();
                    TableCell coordinateTypeCell      = new TableCell();
                    CheckBox  chkBox                  = new CheckBox();

                    chkBoxCell.Controls.Add(chkBox);

                    // Save student ids in invisible cells to access later
                    studentIdCell.Text              = lblStudId.InnerText;
                    coordinateStudentIdCell.Text    = table.Rows[i]["StudentId"].ToString();
                    studentIdCell.Visible           = false;
                    coordinateStudentIdCell.Visible = false;

                    // Set remaining cell text
                    coordinateLastNameCell.Text  = table.Rows[i]["LastName"].ToString();
                    coordinateFirstNameCell.Text = table.Rows[i]["FirstName"].ToString();
                    coordinateTypeCell.Text      = table.Rows[i]["CoordType"].ToString();

                    // Add cells to new row
                    row.Cells.Add(chkBoxCell);
                    row.Cells.Add(studentIdCell);
                    row.Cells.Add(coordinateStudentIdCell);
                    row.Cells.Add(coordinateLastNameCell);
                    row.Cells.Add(coordinateFirstNameCell);
                    row.Cells.Add(coordinateTypeCell);

                    // Add new row to table
                    tblCoordinates.Rows.Add(row);

                    // Save table to session variable as an array
                    saveTableToSession(tblCoordinates, coordinateTable);
                }
            }

            pnlCoordinates.Visible = true;
        }