private void DeleteAttributeInDatabase(string selected)
 {
     PriceTableAzure price = new PriceTableAzure();
     string results = Search.GetAttributes(hdfPriceID.Value);
     var attributes = results.Split(new char[] { '|' }).ToList();
     if (attributes.Contains(selected))
     {
         attributes.Remove(selected);
     }
     string newItems = "|";
     foreach (var item in attributes)
     {
         newItems = item + newItems;
     }
     Search.DeleteAttribute(price);
 }
        protected void PriceDetails_Click(object sender, EventArgs e)
        {
            string attributes = "|";
            PriceTableAzure price = new PriceTableAzure();

            price.MonthlyRental = txtMonthlyrental.Text;
            price.Description = txtDescription.Text;

            string propID;
            if (Session["propID"] != null)
            {//Populate the propertyid and the attributeid
                propID = (string)Session["propID"];
                price.PropertyID = Guid.Parse(propID);

            }
            else
            {//If the propertyid in not available from the session get from the hidden control
                propID = Convert.ToString(PropertyIDFromDataBase.Value);

                price.PropertyID = Guid.Parse(propID);

                Session["propID"] = propID;
            }

            if (tblAccessGate.Visible == true)
            {
                if (AccessGate.SelectedValue == "Yes")
                {
                    attributes = attributes + "Access Gate" + "|";
                }
                else if (AccessGate.SelectedValue == "No")
                {

                }

            }

            if (tblAirCon.Visible == true)
            {
                if (AirCon.SelectedValue == "Yes")
                {
                    attributes = attributes + "Air Conditioning |";
                }

            }

            if (tblAlarm.Visible == true)
            {

                if (Alarm.SelectedValue == "Yes")
                {
                    attributes = attributes + "Alarm System |";
                }

            }

            if (tblBalcony.Visible == true)
            {

                if (Balcony.SelectedValue == "Yes")
                {
                    attributes = attributes + "Balcony |";
                }

            }

            if (tblBathrooms.Visible == true)
            {
                attributes = attributes + txtBathrooms.Text + " Bathroom |";

            }

            if (tblBedrooms.Visible == true)
            {
                attributes = attributes + txtBedrooms.Text + " Bedroom|";

            }

            if (tblBorehole.Visible == true)
            {
                if (Borehole.SelectedValue == "Yes")
                {
                    attributes = attributes + "Borehole |";
                }

            }
            if (tblBuiltinBraai.Visible == true)
            {

                if (BuiltinBraai.SelectedValue == "Yes")
                {
                    attributes = attributes + "Built-in Braai |";
                }

            }
            if (tblBuiltinCupboards.Visible == true)
            {

                if (BuiltinCupboards.SelectedValue == "Yes")
                {
                    attributes = attributes + "Built-in Cupboard |";
                }

            }
            if (tblBusinessType.Visible == true)
            {
                if (!BusinessType.SelectedValue.Contains("Choose one"))
                {
                    attributes = attributes + BusinessType.SelectedValue + "|";

                }
            }

            if (tblCarports.Visible == true)
            {
                attributes = attributes + txtCarports.Text + " Carports |";

            }

            if (tblClubHouse.Visible == true)
            {

                if (clubHouse.SelectedValue == "Yes")
                {
                    attributes = attributes + "Club House |";
                }

            }
            for (int i = 0; i < chbHomeType.Items.Count; i++)
            {
                if (chbHomeType.Items[i].Selected)
                {
                    attributes = attributes + chbHomeType.Items[i].Value + " |";
                }
            }
            if (tblHomeType.Visible == true)
            {
                if (!HomeType.SelectedValue.Contains("Choose one"))
                {
                    // attributes = attributes + HomeType.SelectedValue +" |";

                }
            }

            if (tblDeck.Visible == true)
            {

                if (ddlDeck.SelectedValue == "Yes")
                {
                    attributes = attributes + " Deck |";
                }

            }

            if (tblDiningArea.Visible == true)
            {
                attributes = attributes + txtDiningArea.Text + " Dining Area |";

            }

            if (tblElectricfencing.Visible == true)
            {

                if (ddlElectricFencing.SelectedValue == "Yes")
                {
                    attributes = attributes + "Electric Fencing |";
                }

            }

            if (tblElectricityIncluded.Visible == true)
            {

                if (ddlElectricityIncluded.SelectedValue == "Yes")
                {
                    attributes = attributes + "Electricity Included |";
                }

            }

            if (tblEnSuite.Visible == true)
            {
                attributes = attributes + txtEnSuite.Text + " En-Suite |";

            }

            if (tblEntranceHall.Visible == true)
            {

                if (ddlEntranceHall.SelectedValue == "Yes")
                {
                    attributes = attributes + "Entrance Hall |";
                }

            }

            if (tblFamilyTV.Visible == true)
            {

                if (ddlFamilyTV.SelectedValue == "Yes")
                {
                    attributes = attributes + "Family TV |";
                }

            }

            if (tblFarmType.Visible == true)
            {

                if (!ddlFarmType.SelectedValue.Contains("Choose one"))
                {
                    attributes = attributes + ddlFarmType.SelectedValue + "|";

                }
            }

            if (tblFarmBuilding.Visible == true)
            {
                if (!ddlFarmBuilding.SelectedValue.Contains("Choose one"))
                {
                    attributes = attributes + ddlFarmBuilding.SelectedValue + "|";

                }
            }

            if (tblFarmName.Visible == true)
            {
                attributes = attributes + txtfarmName.Text + "|";

            }

            if (tblFence.Visible == true)
            {

                if (ddlFence.SelectedValue == "Yes")
                {
                    attributes = attributes + "Fence|";
                }

            }

            if (tblFinishes.Visible == true)
            {

                if (ddlFinishes.SelectedValue == "Yes")
                {
                    attributes = attributes + "Finishes|";
                }

            }

            if (tblfirePlace.Visible == true)
            {

                if (ddlFirePlace.SelectedValue == "Yes")
                {
                    attributes = attributes + "Fire|";
                }

            }

            if (tblFlatlet.Visible == true)
            {

                if (ddlFlatlet.SelectedValue == "Yes")
                {
                    attributes = attributes + "Flatlet|";
                }

            }

            if (tblFloorArea.Visible == true)
            {
                attributes = attributes + txtFloorArea.Text + " Floors|";

            }

            if (tblFurnished.Visible == true)
            {

                if (ddlFurnished.SelectedValue == "Yes")
                {
                    attributes = attributes + "Furnished|";
                }

            }

            if (tblGarage.Visible == true)
            {
                attributes = attributes + txtGarage.Text + " Garage|";

            }

            if (tblGarden.Visible == true)
            {

                if (ddlGarden.SelectedValue == "Yes")
                {
                    attributes = attributes + "Garden |";
                }

            }

            if (tblGardenCottage.Visible == true)
            {

                if (ddlGardenCottage.SelectedValue == "Yes")
                {
                    attributes = attributes + "Garden Cottage |";
                }

            }

            if (tblGolf.Visible == true)
            {

                if (ddlGolf.SelectedValue == "Yes")
                {
                    attributes = attributes + "Golf |";
                }

            }

            if (tblGuestToilet.Visible == true)
            {

                if (ddlGuestToilet.SelectedValue == "Yes")
                {
                    attributes = attributes + "Guest Toilet |";
                }

            }

            if (tblGym.Visible == true)
            {

                if (ddlGym.SelectedValue == "Yes")
                {
                    attributes = attributes + "Gym |";
                }

            }

            if (tblDisabilityAccess.Visible == true)
            {

                if (ddlDisabilityAccess.SelectedValue == "Yes")
                {
                    attributes = attributes + "Disability Access |";
                }

            }
            price.Attributes = attributes;
            Search.AddPrice(price, hdfPriceID.Value);

            //Search.UpdateLatLng(Convert.ToInt16(propID), hdfLatitude.Value.ToString(), hdfLongitude.Value.ToString());

            Session["propID"] = propID;
            //ltvThumbnail.DataSource = Search.GetThumbnails(key.UserID, Convert.ToInt32(propID));
            //ltvThumbnail.DataBind();
            propertypictures.Attributes.Add("src", "/Members/maps/PropertyPictures.aspx?propertyimagesID=" + propID);
            MultiView1.ActiveViewIndex = 3;

            LoadSelectedState(4);
        }