//--------------------------------------------------------------------------- //Update Dates private void BtnUpdate_Click(object sender, EventArgs e) { string chkIn = txtArriveDate.Text; string chkOut = txtDepartDate.Text; if (Convert.ToDateTime(chkIn) < DateTime.Now) { Response.Write("<script>alert('Please select a date in the future')</script>"); } else if (Convert.ToDateTime(chkOut) < Convert.ToDateTime(chkIn)) { Response.Write("<script>alert('Please select a depart date that is after the arrival date')</script>"); } else { string booking = Session["bookingID"].ToString(); string sqlQuery = @"UPDATE Booking SET CheckInDate = '" + chkIn + "'," + "CheckOutDate = '" + chkOut + "'" + "WHERE BookingID = '" + booking + "'"; ConClass connection = new ConClass(); connection.retrieveData(sqlQuery); Response.Redirect("~/WardenBookings.aspx"); } }
public static string makeBooking(string volID, string chkIn, string chkOut) { string message = "successful"; int volunteerID = int.Parse(volID); if (Convert.ToDateTime(chkIn) < DateTime.Now) { } else if (Convert.ToDateTime(chkOut) < Convert.ToDateTime(chkIn)) { } else { string insertBookingQuery = @"INSERT into Booking(VolunteerID, CheckInDate, CheckOutDate, NumFemaleGuests, NumMaleGuests, Confirmed) VALUES('" + volunteerID + "', '" + chkIn + "', '" + chkOut + "', '0', '0', 'False')"; ConClass insertBookingConnect = new ConClass(); insertBookingConnect.retrieveData(insertBookingQuery); string bookingQuery = "SELECT BookingID FROM Booking WHERE VolunteerID = '" + volunteerID + "' AND CheckInDate = '" + chkIn + "' AND CheckOutDate = '" + chkOut + "'"; ConClass bookingConnect = new ConClass(); bookingConnect.retrieveData(bookingQuery); int bookingID = (int)bookingConnect.SQLTable.Rows[0].ItemArray.GetValue(0); string genderQuery = @"SELECT Gender FROM Volunteer WHERE VolunteerID = '" + volunteerID + "'"; ConClass genderConnect = new ConClass(); genderConnect.retrieveData(genderQuery); string gender = (string)genderConnect.SQLTable.Rows[0].ItemArray.GetValue(0); if (gender == "Male") { string setGenderQuery = @"UPDATE Booking SET NumMaleGuests = NumMaleGuests + 1 " + "WHERE BookingID = '" + bookingID + "'"; ConClass setGenderConnection = new ConClass(); setGenderConnection.retrieveData(setGenderQuery); } else { string setGenderQuery = @"UPDATE Booking SET NumFemaleGuests = NumFemaleGuests + 1 " + "WHERE BookingID = '" + bookingID + "'"; ConClass setGenderConnection = new ConClass(); setGenderConnection.retrieveData(setGenderQuery); } string bedQuery = "INSERT into BedAssignment(BookingID, VolunteerID) VALUES('" + bookingID + "', '" + volunteerID + "')"; ConClass bedConnect = new ConClass(); bedConnect.retrieveData(bedQuery); } return(message); //Response.Redirect("~/ConfirmBooking.aspx"); }
protected void btnSearch_Click(object sender, EventArgs e) { if (Convert.ToDateTime(txtDateFrom.Text) < DateTime.Now) { Response.Write("<script>alert('Please select a date in the future')</script>"); } else if (Convert.ToDateTime(txtDateTo.Text) < Convert.ToDateTime(txtDateFrom.Text)) { Response.Write("<script>alert('Please select a date to that is after date from')</script>"); } else { string sqlQuery = @"SELECT Booking.BookingID, Volunteer.FirstName, Volunteer.Surname, Booking.CheckInDate, Booking.CheckOutDate, Booking.NumFemaleGuests, Booking.NumMaleGuests, Booking.Confirmed FROM Booking JOIN Volunteer ON Booking.VolunteerID = Volunteer.VolunteerID WHERE Confirmed = 'True' AND Booking.CheckInDate >= '" + txtDateFrom.Text + "' AND Booking.CheckInDate <= '" + txtDateTo.Text + "'"; ConClass connection = new ConClass(); connection.retrieveData(sqlQuery); DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[8] { new DataColumn("BookingId", typeof(int)), new DataColumn("FirstName", typeof(string)), new DataColumn("Surname", typeof(string)), new DataColumn("CheckIn", typeof(string)), new DataColumn("CheckOut", typeof(string)), new DataColumn("NumFemale", typeof(int)), new DataColumn("NumMale", typeof(int)), new DataColumn("Confirmed", typeof(Boolean)) }); foreach (DataRow dr in connection.SQLTable.Rows) { int bookingId = (int)dr[0]; string firstName = (string)dr[1]; string surname = (string)dr[2]; string checkInDate = ((DateTime)dr[3]).ToShortDateString(); string checkOutDate = ((DateTime)dr[4]).ToShortDateString(); int numberOfFemale = (int)dr[5]; int numberOfMale = (int)dr[6]; Boolean confirmed = (Boolean)dr[7]; dt.Rows.Add(bookingId, firstName, surname, checkInDate, checkOutDate, numberOfFemale, numberOfMale, confirmed); } this.grdConfirmed.DataSource = dt; this.grdConfirmed.DataBind(); } }
//get number of textboxes and values private int getNumOfPeople() { string booking = getBookingID(); string genderQuery = @"SELECT NumFemaleGuests, NumMaleGuests FROM Booking WHERE BookingID = '" + booking + "'"; ConClass genderConnect = new ConClass(); genderConnect.retrieveData(genderQuery); //Get number of people linked to booking int n = (int)genderConnect.SQLTable.Rows[0].ItemArray.GetValue(0) + (int)genderConnect.SQLTable.Rows[0].ItemArray.GetValue(1); return(n); }
//DELETE BUTTON TRYOUT--------------------------------------------- private void BtnDelete_Click(object sender, EventArgs e) { string booking = Session["bookingID"].ToString(); string bedQuery = @"DELETE BedAssignment WHERE BookingID = '" + booking + "'"; ConClass bedConnect = new ConClass(); bedConnect.retrieveData(bedQuery); string sqlBooking = @"DELETE Booking WHERE BookingID = '" + booking + "'"; ConClass bookingConnect = new ConClass(); bookingConnect.retrieveData(sqlBooking); Response.Redirect("~/WardenBookings.aspx"); }
private void deleteBooking() { string booking = Session["bookingID"].ToString(); string bedQuery = @"DELETE BedAssignment WHERE BookingID = '" + booking + "'"; ConClass bedConnect = new ConClass(); bedConnect.retrieveData(bedQuery); string sqlBooking = @"DELETE Booking WHERE BookingID = '" + booking + "'"; ConClass bookingConnect = new ConClass(); bookingConnect.retrieveData(sqlBooking); Response.Redirect("~/CreateBooking.aspx"); }
protected void getData() { //Get volunteers name, gender and age and display it string sqlQuery = @"SELECT VolunteerID, FirstName, Surname, DOB, Gender FROM Volunteer WHERE Username = '******'"; ConClass connection = new ConClass(); connection.retrieveData(sqlQuery); //int volID = 0; foreach (DataRow dr in connection.SQLTable.Rows) { txtID.Text = dr[0].ToString(); txtFirstName.Text = (string)dr[1]; txtLastName.Text = (string)dr[2]; txtDOB.Text = ((DateTime)dr[3]).ToString("yyyy-MM-dd"); txtGender.Text = (string)dr[4]; } }
private void bindToGridConfirmed() { string sqlQuery = @"SELECT Booking.BookingID, Volunteer.FirstName, Volunteer.Surname, Booking.CheckInDate, Booking.CheckOutDate, Booking.NumFemaleGuests, Booking.NumMaleGuests, Booking.Confirmed FROM Booking JOIN Volunteer ON Booking.VolunteerID = Volunteer.VolunteerID WHERE Confirmed = 'True' AND Booking.CheckInDate > DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))"; ConClass connection = new ConClass(); connection.retrieveData(sqlQuery); DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[8] { new DataColumn("BookingId", typeof(int)), new DataColumn("FirstName", typeof(string)), new DataColumn("Surname", typeof(string)), new DataColumn("CheckIn", typeof(string)), new DataColumn("CheckOut", typeof(string)), new DataColumn("NumFemale", typeof(int)), new DataColumn("NumMale", typeof(int)), new DataColumn("Confirmed", typeof(Boolean)) }); foreach (DataRow dr in connection.SQLTable.Rows) { int bookingId = (int)dr[0]; string firstName = (string)dr[1]; string surname = (string)dr[2]; string checkInDate = ((DateTime)dr[3]).ToShortDateString(); string checkOutDate = ((DateTime)dr[4]).ToShortDateString(); int numberOfFemale = (int)dr[5]; int numberOfMale = (int)dr[6]; Boolean confirmed = (Boolean)dr[7]; dt.Rows.Add(bookingId, firstName, surname, checkInDate, checkOutDate, numberOfFemale, numberOfMale, confirmed); } this.grdConfirmed.DataSource = dt; this.grdConfirmed.DataBind(); }
private void volBookingsToGrid() { string sqlQuery = @"SELECT BookingID, CheckInDate, CheckOutDate, NumFemaleGuests, NumMaleGuests, confirmed FROM Booking INNER JOIN Volunteer ON Volunteer.VolunteerID = Booking.VolunteerID WHERE Username = '******'"; ConClass connection = new ConClass(); connection.retrieveData(sqlQuery); //ConClass connection = new ConClass(); //connection.retrieveData(sqlVolBookingQuery); DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[6] { new DataColumn("BookingId", typeof(int)), new DataColumn("CheckIn", typeof(string)), new DataColumn("CheckOut", typeof(string)), new DataColumn("NumFemale", typeof(int)), new DataColumn("NumMale", typeof(int)), new DataColumn("Confirmed", typeof(Boolean)) }); foreach (DataRow dr in connection.SQLTable.Rows) { int bookingId = (int)dr[0]; string checkInDate = ((DateTime)dr[1]).ToShortDateString(); string checkOutDate = ((DateTime)dr[2]).ToShortDateString(); int numberOfFemale = (int)dr[3]; int numberOfMale = (int)dr[4]; Boolean confirmed = (Boolean)dr[5]; dt.Rows.Add(bookingId, checkInDate, checkOutDate, numberOfFemale, numberOfMale, confirmed); } this.grdVolunteerBookings.DataSource = dt; this.grdVolunteerBookings.DataBind(); }
private void addData() { string booking = Session["bookingID"].ToString(); string sqlQuery = @"SELECT Volunteer.FirstName, Volunteer.Surname, Booking.CheckInDate, Booking.CheckOutDate, Booking.NumFemaleGuests, Booking.NumMaleGuests FROM Booking JOIN Volunteer ON Booking.VolunteerID = Volunteer.VolunteerID WHERE Booking.BookingID = '" + booking + "'"; ConClass connection = new ConClass(); connection.retrieveData(sqlQuery); foreach (DataRow dr in connection.SQLTable.Rows) { txtFirstName.Text = (string)dr[0]; txtLastName.Text = (string)dr[1]; txtArriveDate.Text = ((DateTime)dr[2]).ToString("yyyy-MM-dd"); txtDepartDate.Text = ((DateTime)dr[3]).ToString("yyyy-MM-dd"); txtNumberOfFemale.Text = Convert.ToString((int)dr[4]); txtNumberOfMale.Text = Convert.ToString((int)dr[5]); } }
private void BtnConfirm_Click(object sender, EventArgs e) { string booking = getBookingID(); int n = getNumOfPeople(); for (int i = 0; i < n; i++) { string bed = dropdown[i].SelectedValue; string id = textBox[i].Text; string bedQuery = @"UPDATE BedAssignment SET BedID = '" + bed + "'" + "WHERE (BookingID = '" + booking + "' AND VolunteerID = '" + id + "')" + "OR (BookingID = '" + booking + "' AND GuestID = '" + id + "')"; ConClass bedConnect = new ConClass(); bedConnect.retrieveData(bedQuery); } string confirmQuery = @"UPDATE Booking SET Confirmed = 'True' WHERE BookingID = '" + booking + "'"; ConClass confirmConnect = new ConClass(); confirmConnect.retrieveData(confirmQuery); Response.Redirect("~/WardenUpdate.aspx"); //----------------------------------------------------------------- }
public static string loadFields(string volID, string chkIn, string chkOut, string fields, string table) { string message = "successful"; //Return message for ajax so it can empty array //Get values from the fields int c = 0; string column = ""; for (c = 0; c <= fields.Split(',').Length - 1; c++) { if (string.IsNullOrEmpty(column)) { column = "[" + fields.Split(',')[c].Replace(" ", "") + "] VARCHAR (100)"; } else { column = column + ", [" + fields.Split(',')[c].Replace(" ", "") + "] VARCHAR (100)"; } } string[] args = fields.Remove(fields.Length - 1, 1).Split(','); if (Convert.ToDateTime(chkIn) < DateTime.Now) { } else if (Convert.ToDateTime(chkOut) < Convert.ToDateTime(chkIn)) { } else { int volunteerID = int.Parse(volID); System.Threading.Thread.Sleep(1000); string bookingQuery = "SELECT BookingID FROM Booking WHERE VolunteerID = '" + volunteerID + "' AND CheckInDate = '" + chkIn + "' AND CheckOutDate = '" + chkOut + "'"; ConClass bookingConnect = new ConClass(); bookingConnect.retrieveData(bookingQuery); int bookingID = (int)bookingConnect.SQLTable.Rows[0].ItemArray.GetValue(0); for (int i = 0; i < args.Length; i++) { if (args[i] == "") { continue; } string firstName = args[i++]; string surname = args[i++]; string dob = args[i++]; string gender = args[i++]; string guestQuery = "INSERT into Guest(FirstName, Surname, DOB, Gender) VALUES('" + firstName + "', '" + surname + "', '" + dob + "', '" + gender + "'); " + "SELECT GuestID FROM Guest WHERE FirstName = '" + firstName + "' AND Surname = '" + surname + "' AND DOB = '" + dob + "'"; ConClass guestConnect = new ConClass(); guestConnect.retrieveData(guestQuery); int guestID = (int)guestConnect.SQLTable.Rows[0].ItemArray.GetValue(0); //int volunteerID = int.Parse(volID); //string bookingQuery = "SELECT BookingID FROM Booking WHERE VolunteerID = '" + volunteerID + "' AND CheckInDate = '" + chkIn + "' AND CheckOutDate = '" + chkOut + "'"; //ConClass bookingConnect = new ConClass(); //bookingConnect.retrieveData(bookingQuery); //int bookingID = (int)bookingConnect.SQLTable.Rows[0].ItemArray.GetValue(0); if (gender == "Male") { string setGenderQuery = @"UPDATE Booking SET NumMaleGuests = NumMaleGuests + 1 " + "WHERE BookingID = '" + bookingID + "'"; ConClass setGenderConnection = new ConClass(); setGenderConnection.retrieveData(setGenderQuery); } else { string setGenderQuery = @"UPDATE Booking SET NumFemaleGuests = NumFemaleGuests + 1 " + "WHERE BookingID = '" + bookingID + "'"; ConClass setGenderConnection = new ConClass(); setGenderConnection.retrieveData(setGenderQuery); } string bedQuery = "INSERT into BedAssignment(BookingID, GuestID) VALUES('" + bookingID + "', '" + guestID + "')"; ConClass bedConnect = new ConClass(); bedConnect.retrieveData(bedQuery); } } return(message); }
private void setTextboxes() { string booking = getBookingID(); string volunteerQuery = @"SELECT Volunteer.VolunteerID, Volunteer.FirstName, Volunteer.Surname, Volunteer.Gender FROM BedAssignment JOIN Volunteer ON BedAssignment.VolunteerID = Volunteer.VolunteerID WHERE BedAssignment.BookingID = '" + booking + "'"; ConClass volunteerConnect = new ConClass(); volunteerConnect.retrieveData(volunteerQuery); string guestQuery = @"SELECT Guest.GuestID, Guest.FirstName, Guest.Surname, Guest.Gender FROM BedAssignment JOIN Guest ON BedAssignment.GuestID = Guest.GuestID WHERE BedAssignment.BookingID = '" + booking + "'"; ConClass guestConnect = new ConClass(); guestConnect.retrieveData(guestQuery); string datesQuery = @"SELECT CheckInDate, CheckOutDate FROM Booking WHERE BookingID = '" + booking + "'"; ConClass datesConnect = new ConClass(); datesConnect.retrieveData(datesQuery); string checkIn = ((DateTime)datesConnect.SQLTable.Rows[0].ItemArray.GetValue(0)).ToString("yyyy-MM-dd"); string checkOut = ((DateTime)datesConnect.SQLTable.Rows[0].ItemArray.GetValue(1)).ToString("yyyy-MM-dd"); string bedNotExistQuery = @"SELECT Bed.BedID FROM Bed WHERE NOT EXISTS (SELECT BedID FROM BedAssignment WHERE BedAssignment.BedID = Bed.BedID)"; ConClass bedNotExistConnect = new ConClass(); bedNotExistConnect.retrieveData(bedNotExistQuery); //Update query to check dates string bedQuery = @"SELECT Bed.BedID FROM Bed JOIN BedAssignment ON Bed.BedID = BedAssignment.BedID JOIN Booking ON BedAssignment.BookingID = Booking.BookingID WHERE('" + checkIn + "' NOT BETWEEN Booking.CheckInDate AND Booking.CheckOutDate)" + "AND('" + checkOut + "' NOT BETWEEN Booking.CheckInDate AND Booking.CheckOutDate)" + "AND(Booking.CheckInDate NOT BETWEEN '" + checkIn + "' AND '" + checkOut + "')" + "AND(Booking.CheckOutDate NOT BETWEEN '" + checkIn + "' AND '" + checkOut + "')"; ConClass bedConnect = new ConClass(); bedConnect.retrieveData(bedQuery); DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[1] { new DataColumn("BedID", typeof(string)) }); foreach (DataRow dr in bedConnect.SQLTable.Rows) { string bedId = (string)dr[0]; dt.Rows.Add(bedId); } foreach (DataRow dr in bedNotExistConnect.SQLTable.Rows) { string bedId = (string)dr[0]; dt.Rows.Add(bedId); } dt.DefaultView.Sort = "BedID ASC"; int n = getNumOfPeople(); int i = 0; int j = 0; textBox = new TextBox[n]; TextBox[] txtBox = new TextBox[n]; Label[] label = new Label[n]; dropdown = new DropDownList[n]; Panel[] panel = new Panel[n]; Panel[] subPanel = new Panel[n * 5]; //Fill Volunteer foreach (DataRow dr in volunteerConnect.SQLTable.Rows) { panel[i] = new Panel(); panel[i].CssClass = "input-group"; form1.Controls.Add(panel[i]); subPanel[j] = new Panel(); subPanel[j].CssClass = "input-group-prepend"; label[i] = new Label(); label[i].Text = " Volunteer ID: "; label[i].CssClass = "input-group-text"; textBox[i] = new TextBox(); textBox[i].Text = Convert.ToString((int)dr[0]); textBox[i].ReadOnly = true; textBox[i].CssClass = "form-control"; subPanel[j].Controls.Add(label[i]); panel[i].Controls.Add(subPanel[j]); panel[i].Controls.Add(textBox[i]); j++; subPanel[j] = new Panel(); subPanel[j].CssClass = "input-group-prepend"; label[i] = new Label(); label[i].Text = " FirstName: "; label[i].CssClass = "input-group-text"; txtBox[i] = new TextBox(); txtBox[i].Text = (string)dr[1]; txtBox[i].ReadOnly = true; txtBox[i].CssClass = "form-control"; subPanel[j].Controls.Add(label[i]); panel[i].Controls.Add(subPanel[j]); panel[i].Controls.Add(txtBox[i]); j++; subPanel[j] = new Panel(); subPanel[j].CssClass = "input-group-prepend"; label[i] = new Label(); label[i].Text = " Surname: "; label[i].CssClass = "input-group-text"; txtBox[i] = new TextBox(); txtBox[i].Text = (string)dr[2]; txtBox[i].ReadOnly = true; txtBox[i].CssClass = "form-control"; subPanel[j].Controls.Add(label[i]); panel[i].Controls.Add(subPanel[j]); panel[i].Controls.Add(txtBox[i]); j++; subPanel[j] = new Panel(); subPanel[j].CssClass = "input-group-prepend"; label[i] = new Label(); label[i].Text = " Gender: "; label[i].CssClass = "input-group-text"; txtBox[i] = new TextBox(); txtBox[i].Text = (string)dr[3]; txtBox[i].ReadOnly = true; txtBox[i].CssClass = "form-control"; subPanel[j].Controls.Add(label[i]); panel[i].Controls.Add(subPanel[j]); panel[i].Controls.Add(txtBox[i]); j++; subPanel[j] = new Panel(); subPanel[j].CssClass = "input-group-prepend"; label[i] = new Label(); label[i].Text = " Bed: "; label[i].CssClass = "input-group-text"; dropdown[i] = new DropDownList(); dropdown[i].AutoPostBack = true; dropdown[i].CssClass = "form-control"; dropdown[i].SelectedIndexChanged += new EventHandler(dropdown_SelectedValueChanged); subPanel[j].Controls.Add(label[i]); panel[i].Controls.Add(subPanel[j]); panel[i].Controls.Add(dropdown[i]); dropdown[i].DataSource = dt; dropdown[i].DataTextField = "BedID"; dropdown[i].DataValueField = "BedID"; dropdown[i].DataBind(); dropdown[i].Items.Insert(0, new ListItem(" Choose Bed ", "0")); dropdown[i].SelectedIndex = 0; panel[i].Controls.Add(new LiteralControl("<br />")); panel[i].Controls.Add(new LiteralControl("<br />")); } //Fill guests foreach (DataRow dr in guestConnect.SQLTable.Rows) { i++; j++; panel[i] = new Panel(); panel[i].CssClass = "input-group"; form1.Controls.Add(panel[i]); subPanel[j] = new Panel(); subPanel[j].CssClass = "input-group-prepend"; label[i] = new Label(); label[i].Text = " Guest ID: "; label[i].CssClass = "input-group-text"; textBox[i] = new TextBox(); textBox[i].Text = Convert.ToString((int)dr[0]); textBox[i].ReadOnly = true; textBox[i].CssClass = "form-control"; subPanel[j].Controls.Add(label[i]); panel[i].Controls.Add(subPanel[j]); panel[i].Controls.Add(textBox[i]); j++; subPanel[j] = new Panel(); subPanel[j].CssClass = "input-group-prepend"; label[i] = new Label(); label[i].Text = " FirstName: "; label[i].CssClass = "input-group-text"; txtBox[i] = new TextBox(); txtBox[i].Text = (string)dr[1]; txtBox[i].ReadOnly = true; txtBox[i].CssClass = "form-control"; subPanel[j].Controls.Add(label[i]); panel[i].Controls.Add(subPanel[j]); panel[i].Controls.Add(txtBox[i]); j++; subPanel[j] = new Panel(); subPanel[j].CssClass = "input-group-prepend"; label[i] = new Label(); label[i].Text = " Surname: "; label[i].CssClass = "input-group-text"; txtBox[i] = new TextBox(); txtBox[i].Text = (string)dr[2]; txtBox[i].ReadOnly = true; txtBox[i].CssClass = "form-control"; subPanel[j].Controls.Add(label[i]); panel[i].Controls.Add(subPanel[j]); panel[i].Controls.Add(txtBox[i]); j++; subPanel[j] = new Panel(); subPanel[j].CssClass = "input-group-prepend"; label[i] = new Label(); label[i].Text = " Gender: "; label[i].CssClass = "input-group-text"; txtBox[i] = new TextBox(); txtBox[i].Text = (string)dr[3]; txtBox[i].ReadOnly = true; txtBox[i].CssClass = "form-control"; subPanel[j].Controls.Add(label[i]); panel[i].Controls.Add(subPanel[j]); panel[i].Controls.Add(txtBox[i]); j++; subPanel[j] = new Panel(); subPanel[j].CssClass = "input-group-prepend"; label[i] = new Label(); label[i].Text = " Bed: "; label[i].CssClass = "input-group-text"; dropdown[i] = new DropDownList(); dropdown[i].AutoPostBack = true; dropdown[i].CssClass = "form-control"; dropdown[i].SelectedIndexChanged += new EventHandler(dropdown_SelectedValueChanged); subPanel[j].Controls.Add(label[i]); panel[i].Controls.Add(subPanel[j]); panel[i].Controls.Add(dropdown[i]); dropdown[i].DataSource = dt; dropdown[i].DataTextField = "BedID"; dropdown[i].DataValueField = "BedID"; dropdown[i].DataBind(); dropdown[i].Items.Insert(0, new ListItem(" Choose Bed ", "0")); dropdown[i].SelectedIndex = 0; //Should update dropdown after one has a selected value panel[i].Controls.Add(new LiteralControl("<br />")); panel[i].Controls.Add(new LiteralControl("<br />")); } }