protected void CheckAvailabilitySelectedDates_Click(object sender, EventArgs e) { if (Session["SelectedDates"] != null) { //create booking elements for grid view display sessionBookingElements = BookingElement.CreateBookingElementsForUserSelectedDates ((List <DateTime>)Session["SelectedDates"], currentRoomData); BookingElement.AddRoomRateByDate(currentRoomData, ref sessionBookingElements); BookingElement.AddAvailabilityToBookingElements(ref sessionBookingElements); //List<BookingElement> availableBookingElements = BookingElement.BookingElementsWithAvailability(ref sessionBookingElements); gvAvailability.DataSource = sessionBookingElements; gvAvailability.DataBind(); foreach (GridViewRow row in gvAvailability.Rows) { DropDownList dl = (DropDownList)row.FindControl("ddlUserGuests"); int max = int.Parse(gvAvailability.Rows[row.RowIndex].Cells[2].Text); int[] ddlSource = Enumerable.Range(0, max + 1).ToArray(); dl.DataSource = ddlSource; dl.DataBind(); } UpdatePanelReturnAvailability.Update(); } }