protected void FindRental_Click(object sender, EventArgs e) { if (AddressSearchList.SelectedIndex == 0 || AddressSearchList.Items.Count < 1) { errormsgs.Add("Select a rental address to maintain."); LoadMessageDisplay(errormsgs, "alert alert-danger"); } else { try { RentalsController rentalsctrlr = new RentalsController(); Rentals info = null; info = rentalsctrlr.Rentals_FindByID(int.Parse(AddressSearchList.SelectedValue)); AddressesController addressctrlr = new AddressesController(); Addresses address = null; List <Addresses> alladdresses = addressctrlr.Address_List(); address = addressctrlr.Addresses_FindByID(info.AddressID); if (info == null) { errormsgs.Add("Cannot find Rental in database."); LoadMessageDisplay(errormsgs, "alert alert-danger"); Clear_Click(sender, e); } else { RentalID.Text = info.RentalID.ToString(); AddressNumber.Text = address.Number; AddressStreet.Text = address.Street; alladdresses.Sort((x, y) => x.FullAddress.CompareTo(y.FullAddress)); AddressDetailList.DataSource = alladdresses; AddressDetailList.DataTextField = nameof(Addresses.FullAddress); AddressDetailList.DataValueField = nameof(Addresses.AddressID); AddressDetailList.DataBind(); AddressDetailList.Items.Insert(0, "Select an Address..."); AddressDetailList.SelectedValue = address.AddressID.ToString(); AddressID.Text = address.AddressID.ToString(); SelectedAddress.Text = address.FullAddress; if (info.RentalTypeID.HasValue) { RentalTypeList.SelectedValue = info.RentalTypeID.ToString(); } else { RentalTypeList.SelectedIndex = 0; } MonthlyRent.Text = string.Format("{0:0.00}", info.MonthlyRent); Vacancies.Text = info.Vacancies.ToString(); MaxVacancy.Text = info.MaxVacancy.ToString(); DamageDeposit.Text = string.IsNullOrEmpty(info.DamageDeposit.ToString()) ? "" : string.Format("{0:0.00}", info.DamageDeposit); AvailableDate.Text = string.IsNullOrEmpty(info.AvailableDate.ToString()) ? "" : info.AvailableDate.Value.ToString("yyyy-MM-dd"); } } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } } }