This is a migrated thread and some comments may be shown as answers.

[Solved] Rad Grid with Dynamic Control

1 Answer 195 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mani
Top achievements
Rank 1
mani asked on 30 Mar 2009, 02:21 PM
Hi
      I have used the User Control with in Grid . In this user control to have dynamic generation Controls.  When I Click the Grid Edit Mode that Time the User Control is Showing. I want to need that Dynamic Control id... So i go and get view source code that time the control Id is Generated.. the number of rows is displaying in the grid.. ok... Each and Every to have the different Id's But i want to common id.. Because i will increase the for loop and to do some process...

for example
I Click the fourth row

((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtSofaBed" + i.ToString()]) != null)

ok here each and every row  chancing the below bold areas like this one($ctl00$ctl13$)
((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtSofaBed" + i.ToString()]) != null)


My source Code is below Please Check to give me

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Collections;

using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
using Microsoft.Practices.EnterpriseLibrary.Validation.Integration;
using Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet;


using Telerik.Web.UI;
using Com.JetSoft.JetSoftFramework.Property;
using Com.JetSoft.JetSoftComponent.Property;
using Com.JetSoft.JetSoftFramework.System;
using Com.JetSoft.JetSoftComponent.System;
using Com.JetSoft.JetSoftComponent.Contact;
using Com.JetSoft.JetSoftFramework.Contact;
using Com.JetSoft.Admin.Base;
using Resources;
using System.Configuration;

namespace JetSoftAdmin.UserControl
{
    public partial class PropertySearch : System.Web.UI.UserControl
    {
        #region "Page Level Declaration"
        AreaData areaData = new AreaData();
        AreaManager areaManager = new AreaManager();
        PropertyData propertyData = new PropertyData();
        Com.JetSoft.JetSoftComponent.Property.PropertyManager propertyManager = new Com.JetSoft.JetSoftComponent.Property.PropertyManager();       
        GeoAreasManager geoAreasManager = new GeoAreasManager();
        ContactData contactData = new ContactData();
        ContactManager contactManager = new ContactManager();
        CategoryManager categoryManager = new CategoryManager();
        AgreementTemplateData agreementTemplateData = new AgreementTemplateData();
        AgreementManager agreementManager = new AgreementManager();
        List<PropertyData> aPropertyDataList = null;      
        HiddenField hdnUtilitiesDetailsId = new HiddenField();
        long countBedrows;
        int j;
        int ValueSize;
        
        private Hashtable AmenitiedChecked
        {
            get
            {
                object res = ViewState["_cc"];
                if (res == null)
                {
                    res = new Hashtable();
                    ViewState["_cc"] = res;
                }

                return (Hashtable)res;
            }
        }


        #endregion

        /// <summary>
        /// Page Load Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
                           
                txtPropertyId.Text = (JSSessionHandler.GetSessionValue("PropertyId").ToString());
                aPropertyDataList = propertyManager.GetPropertyByID(Convert.ToInt64(txtPropertyId.Text));
               
                ValueSize = Convert.ToInt32(ConfigurationSettings.AppSettings["PropertyDropDownValueSize"]);

        }


        //Page Prerenter Page

        protected void Page_PreRender(object sender, EventArgs e)
        {

            //Load Owner Agreement Data From DB
            LoadAgreementTemplateOwnerDataFromDB();

            //Load Renter Agreement Details Data From DB
            LoadAgreementTemplateRenterDataFromDB();

            //Load The Property Data's From DataBase to Page
            LoadPropertyFromDataBase();

            //Load the Utilities Details
            //LoadUtilitiesDetailsFromDB();

            //Load the Amentities Detials From DataBase
             LoadPropertyUtilitiesDetailFromDB();
             
            //Load Amenities Details From Page
           //LoadAmenitiesDetailsFromDB();         

           //Load The Amentities Details From DataBase
            LoadPropertyAmenitiesDetailFromDB();

            //Dynamic Bed Layout Details From Pages
            DynamicBedLayoutDetails();
        }


        public void LoadPropertyFromDataBase()
        {
            //load Master information From DB
            LoadMasterInformationFromDB();

            //Load the Property Informations Details From DataBase
            LoadPropertyDetailsFromDB();

            //Load the Contact Informations From DataBase
            LoadContactDetailsFromDB();

            //Load All Drop Down Data's From Page
            LoadAllDropDownPropertyDataFromDB();
             
        }

        #region "DropDown"


        //Load All DropDown Data's From Page
        public void LoadAllDropDownPropertyDataFromDB()
        {
            // load the Destination Details From DB
            LoadDestinationFromDB();

            //Load the Country Details From DB
            LoadCountryDetailsFromDB();

            //Load the State Details From DB
            LoadStateDetailsFromDB();

            //Load the Manager Details From DB
            LoadManagerDataFromDB();

            //Load the Owner Details From DB
            LoadOwnerDataFromDB();

            //Load the Refferal Agent Data From DB
            LoadRefferalAgentDataFromDB();

            //Load the Cleaning Company Data From DB
            LoadCleaningCompanyDataFromDB();

            //Load All Deposit Details for Charges
            LoadAllDepositFromDB();

            //Load All the Details from Page
            LoadAllGarageFromDB();

            //Load Feature Property From DB
            LoadAllPropertyFeatureFromDB();


            //Load Unit Type Data From Page
            LoadAllUnitTypeFromDB();

            //load Style From DB
            LoadAllPropertyStyleFromDB();


        
        }

        /// <summary>
        /// Load Destination Data From DataBase
        /// </summary>
        public void LoadDestinationFromDB()
        {
            try
            {
                IList<AreaData> areaSearch = new List<AreaData>();
                areaSearch = areaManager.GetDestinations();
                cmbMasterInfoDestination.DataSource = areaSearch;
                cmbMasterInfoDestination.DataTextField = "Name";
                cmbMasterInfoDestination.DataValueField = "ID";
                cmbMasterInfoDestination.DataBind();
                
                RadComboBoxItem cmbParentArea = new RadComboBoxItem();
                cmbParentArea.Text = " ";
                cmbMasterInfoDestination.Items.Insert(0, cmbParentArea);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
      

        /// <summary>
        /// Load the Country Data in Personal Info Tab
        /// </summary>
        public void LoadCountryDetailsFromDB()
        {
            try
            {
                //Show only active countries
                bool result = bool.Parse(AdminResource.boolTrue);
                IList<CountryData> listCountry = new List<CountryData>();
                listCountry = geoAreasManager.GetAllCountries(result);
                cmbPropertyAddressCountry.DataSource = listCountry;
                cmbPropertyAddressCountry.DataTextField = "Name";
                cmbPropertyAddressCountry.DataValueField = "ID";
                cmbPropertyAddressCountry.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }



        /// <summary>
        /// Load the Default US State
        /// </summary>

        public void LoadStateDetailsFromDB()
        {
            try
            {
                IList<StateData> StatesList = new List<StateData>();
                StatesList = geoAreasManager.GetStatesByCountryId(1);
                cmbPropertyAddressState.DataTextField = "Name";
                cmbPropertyAddressState.DataValueField = "ID";
                cmbPropertyAddressState.DataSource = StatesList;
                cmbPropertyAddressState.DataBind();
            }
            catch
            {
                //TODO : Implement the throw
            }
        }
        /// <summary>
        /// Load the All the Manager Data From Page
        /// </summary>
        public void LoadManagerDataFromDB()
        {

            IList<ContactData> contactData = new List<ContactData>();
            contactData = contactManager.GetAllManager();
            cmbContactManager.DataSource = contactData;
            cmbContactManager.DataTextField = "FullName";
            cmbContactManager.DataValueField = "ID";
            cmbContactManager.DataBind();

            RadComboBoxItem cmbmanager = new RadComboBoxItem();
            cmbmanager.Text = " ";
            cmbContactManager.Items.Insert(0, cmbmanager);
        }


        /// <summary>
        /// Load the Owner Detail for Contact Tab
        /// </summary>
        public void LoadOwnerDataFromDB()
        {
            IList<ContactData> contactData = new List<ContactData>();
            contactData = contactManager.GetAllOwner();
            cmbContactOwner.DataSource = contactData;
            cmbContactOwner.DataTextField = "FullName";
            cmbContactOwner.DataValueField = "ID";
            cmbContactOwner.DataBind();

            RadComboBoxItem cmbowner = new RadComboBoxItem();
            cmbowner.Text = " ";
            cmbContactOwner.Items.Insert(0, cmbowner);
        }



        /// <summary>
        /// Load the All Owner Agreements
        /// </summary>
        public void LoadAgreementTemplateOwnerDataFromDB()
        {
            IList<AgreementTemplateData> agreementData = new List<AgreementTemplateData>();
            agreementData = agreementManager.GetAllTemplateTypeById(1);
            cmbMasterInfoOwnerAgreement.DataSource = agreementData;
            cmbMasterInfoOwnerAgreement.DataTextField = "AgreementName";
            cmbMasterInfoOwnerAgreement.DataValueField = "ID";
            cmbMasterInfoOwnerAgreement.DataBind();

            RadComboBoxItem cmbagreement = new RadComboBoxItem();
            cmbagreement.Text = " ";
            cmbMasterInfoOwnerAgreement.Items.Insert(0, cmbagreement);
        }


        /// <summary>
        /// Load the All Renter Agreements
        /// </summary>
        public void LoadAgreementTemplateRenterDataFromDB()
        {
            IList<AgreementTemplateData> agreementData = new List<AgreementTemplateData>();
            agreementData = agreementManager.GetAllTemplateTypeById(2);
            cmbMasterInfoRenterAgreement.DataSource = agreementData;
            cmbMasterInfoRenterAgreement.DataTextField = "AgreementName";
            cmbMasterInfoRenterAgreement.DataValueField = "ID";
            cmbMasterInfoRenterAgreement.DataBind();

            RadComboBoxItem cmbRenterAgreement = new RadComboBoxItem();
            cmbRenterAgreement.Text = " ";
            cmbMasterInfoRenterAgreement.Items.Insert(0, cmbRenterAgreement);
        }


        /// <summary>
        /// Load the Refferal Agent Details Detail for Contact Tab
        /// </summary>
        public void LoadRefferalAgentDataFromDB()
        {
            IList<ContactData> contactData = new List<ContactData>();
            contactData = contactManager.GetAllReferralAgent();
            cmbContactRefferalAgent.DataSource = contactData;
            cmbContactRefferalAgent.DataTextField = "FullName";
            cmbContactRefferalAgent.DataValueField = "ID";
            cmbContactRefferalAgent.DataBind();

            RadComboBoxItem cmbrefferalAgent = new RadComboBoxItem();
            cmbrefferalAgent.Text = " ";
            cmbContactRefferalAgent.Items.Insert(0, cmbrefferalAgent);
        }

        /// <summary>
        /// Load the Cleaning Details Detail for Contact Tab
        /// </summary>
        public void LoadCleaningCompanyDataFromDB()
        {
            IList<ContactData> cleaningCompanyData = new List<ContactData>();
            cleaningCompanyData = contactManager.GetAllCleaningCompany();
            cmbContactsCleaningCompany.DataSource = cleaningCompanyData;
            cmbContactsCleaningCompany.DataTextField = "Company";
            cmbContactsCleaningCompany.DataValueField = "ID";
            cmbContactsCleaningCompany.DataBind();

            RadComboBoxItem cmbcleaningCompany = new RadComboBoxItem();
            cmbcleaningCompany.Text = " ";
            cmbContactsCleaningCompany.Items.Insert(0, cmbcleaningCompany);
        }

        /// <summary>
        /// Get All the Deposit From DB
        /// </summary>
        public void LoadAllDepositFromDB()
        {
            IList<SystemCategoryData> depositData = new List<SystemCategoryData>();
            depositData = categoryManager.GetAllDeposit();
            cmbChargesDeposit.DataSource = depositData;
            cmbChargesDeposit.DataTextField = "Name";
            cmbChargesDeposit.DataValueField = "ID";
            cmbChargesDeposit.DataBind();

            RadComboBoxItem cmbDeposit = new RadComboBoxItem();
            cmbDeposit.Text = " ";
            cmbChargesDeposit.Items.Insert(0, cmbDeposit);
        }

        /// <summary>
        /// Get All the Garage From DB
        /// </summary>
        public void LoadAllGarageFromDB()
        {
            IList<SystemCategoryData> garageData = new List<SystemCategoryData>();
            garageData = categoryManager.GetAllGarage();
            cmbDetailsHighGarage.DataSource = garageData;
            cmbDetailsHighGarage.DataTextField = "Name";
            cmbDetailsHighGarage.DataValueField = "ID";
            cmbDetailsHighGarage.DataBind();

            RadComboBoxItem cmbGarage = new RadComboBoxItem();
            cmbGarage.Text = " ";
            cmbDetailsHighGarage.Items.Insert(0, cmbGarage);
        }


        /// <summary>
        /// Get All the Garage From DB
        /// </summary>
        public void LoadAllPropertyFeatureFromDB()
        {
            IList<SystemCategoryData> propertyFeatureData = new List<SystemCategoryData>();
            propertyFeatureData = categoryManager.GetAllPropertyFeature();
            cmbDetailsFeature.DataSource = propertyFeatureData;
            cmbDetailsFeature.DataTextField = "Name";
            cmbDetailsFeature.DataValueField = "ID";
            cmbDetailsFeature.DataBind();

            RadComboBoxItem cmbGarage = new RadComboBoxItem();
            cmbGarage.Text = " ";
            cmbDetailsFeature.Items.Insert(0, cmbGarage);
        }


        /// <summary>
        /// Get All the Unit Type From DB
        /// </summary>
        public void LoadAllUnitTypeFromDB()
        {
            IList<SystemCategoryData> propertyUnitTypeData = new List<SystemCategoryData>();
            propertyUnitTypeData = categoryManager.GetAllUnitType();
            cmbDetailsUnitType.DataSource = propertyUnitTypeData;
            cmbDetailsUnitType.DataTextField = "Name";
            cmbDetailsUnitType.DataValueField = "ID";
            cmbDetailsUnitType.DataBind();

            RadComboBoxItem cmbUnitType = new RadComboBoxItem();
            cmbUnitType.Text = " ";
            cmbDetailsUnitType.Items.Insert(0, cmbUnitType);
        }

        /// <summary>
        /// Get All the Garage From DB
        /// </summary>
        public void LoadAllPropertyStyleFromDB()
        {
            IList<SystemCategoryData> propertyStyleData = new List<SystemCategoryData>();
            propertyStyleData = categoryManager.GetAllPropertyStyle();
            cmbDetailsStyle.DataSource = propertyStyleData;
            cmbDetailsStyle.DataTextField = "Name";
            cmbDetailsStyle.DataValueField = "ID";
            cmbDetailsStyle.DataBind();

            RadComboBoxItem cmbstyleType = new RadComboBoxItem();
            cmbstyleType.Text = "";
            cmbDetailsStyle.Items.Insert(0, cmbstyleType);
        }

        #endregion

        /// <summary>
        /// Load the Sub Area Details From Database
        /// </summary>
        /// <param name="o">Destination ID</param>
        /// <param name="e"></param>
        protected void cmbMasterInfoDestination_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (cmbMasterInfoArea.SelectedIndex != 0)
            {
                IList<AreaData> subAreaData = new List<AreaData>();
                subAreaData = areaManager.GetSubArea(Convert.ToInt64(cmbMasterInfoDestination.SelectedValue));
                cmbMasterInfoArea.DataSource = subAreaData;
                cmbMasterInfoArea.DataTextField = "Name";
                cmbMasterInfoArea.DataValueField = "ID";
                cmbMasterInfoArea.DataBind();

                RadComboBoxItem cmbSubArea = new RadComboBoxItem();
                cmbSubArea.Text = " ";
                cmbMasterInfoArea.Items.Insert(0, cmbSubArea);
            }
        }

        /// <summary>
        /// Load the Location Details From DataBase
        /// </summary>
        /// <param name="o">Area Id</param>
        /// <param name="e"></param>
        protected void cmbMasterInfoArea_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (cmbMasterInfoLocation.SelectedIndex != 0)
            {
                IList<AreaData> locationData = new List<AreaData>();
                locationData = areaManager.GetChildArea(Convert.ToInt64(cmbMasterInfoArea.SelectedValue));
                cmbMasterInfoLocation.DataSource = locationData;
                cmbMasterInfoLocation.DataTextField = "Name";
                cmbMasterInfoLocation.DataValueField = "ID";
                cmbMasterInfoLocation.DataBind();

                RadComboBoxItem cmbLocation = new RadComboBoxItem();
                cmbLocation.Text = " ";
                cmbMasterInfoLocation.Items.Insert(0, cmbLocation);
            }
        }


    

        /// <summary>
        /// Save the Data From DataBase
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateData())
                {
                    UpdatePropertiesDetails();        //Call the Update Functions              
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }


        /// <summary>
        /// Validate the entries before add/update the contact data
        /// </summary>
        /// <returns></returns>

        private bool ValidateData()
        {

            if ((cmbMasterInfoDestination.SelectedIndex == 0) || (cmbMasterInfoDestination.SelectedIndex == -1))
            {
                ValcmbMasterInfoDestination.Visible = true;
                ValcmbMasterInfoDestination.Text = "Destination is required!";
            }

            if ((cmbDetailsUnitType.SelectedIndex == 0) || (cmbDetailsUnitType.SelectedIndex == -1))
            {
                valpropertybedrooms.Visible = true;
                valpropertybedrooms.Text = "Unit Type is required!";
            }

            if ((cmbContactOwner.SelectedIndex == 0) || (cmbContactOwner.SelectedIndex == -1))
            {
                valOwner.Visible = true;
                valOwner.Text = "Owner is required!";
            }

            if ((cmbMasterInfoOwnerAgreement.SelectedIndex == 0) || (cmbMasterInfoOwnerAgreement.SelectedIndex == -1))
            {
                valcmbAgreementOwner.Visible = true;
                valcmbAgreementOwner.Text = "Owner On line Agreement is required!";

            }

            if ((cmbMasterInfoRenterAgreement.SelectedIndex == 0) || (cmbMasterInfoRenterAgreement.SelectedIndex == -1))
            {
                valCmbAgreementRenter.Visible = true;
                valCmbAgreementRenter.Text = "Rental Agreement is required!";

            }

            if ((cmbChargesDeposit.SelectedIndex == 0) || (cmbChargesDeposit.SelectedIndex == -1))
            {
                valChargesDeposit.Visible = true;
                valChargesDeposit.Text = "Deposit is required!";
            }

            if ((cmbChargesExitCleaningFee.SelectedIndex == 0) || (cmbChargesExitCleaningFee.SelectedIndex == -1))
            {
                valExitCleaningFee.Visible = true;
                valExitCleaningFee.Text = "Exit Cleaning Fee is required!";
            }
            //In addition to the mandatory & format validations, perform the data integrity
            //validations to check for duplicates, dependencies if any

            if (Page.IsValid)
            {

                try
                {
                    UserData sessionUser = (UserData)JSSessionHandler.GetSessionValue("UserData");
                    propertyData.Name = txtMasterInfoPropertyName.Text;

                }
                catch
                {

                }

            }

            return (Page.IsValid);

        }

        // Cancel the Process
        protected void BtnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Content/Property/SearchProperties.aspx");
        }

        protected void UpdatePropertiesDetails()
        {
            try
            {

                LoadMasterInformationDataFromPage();        // Load the Master Information Details from Page             
                loadDetailDataFromPage();                  //  Load Details Tab Details from Page
                LoadAmenitiesFromPage();                   //  Load The Amentities Details from PAge
                LoadUtilitiesDetailsFromPage();
                loadBedLayoutFromPage();
                LoadPropertyCotnactDataFromPage();

                UserData sessionUser = (UserData)JSSessionHandler.GetSessionValue("UserData");
                propertyData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                propertyData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                propertyData.CreatedOn = new DateTime();
                propertyData.UpdatedOn = propertyData.CreatedOn;
                propertyData.Active = true;

                if ((cmbMasterInfoDestination.SelectedIndex == 0) || (cmbMasterInfoDestination.SelectedIndex == -1))
                {
                    ValcmbMasterInfoDestination.Visible = true;
                    ValcmbMasterInfoDestination.Text = "Destination is required!";
                }

                else if ((cmbDetailsUnitType.SelectedIndex == 0) || (cmbDetailsUnitType.SelectedIndex == -1))
                {
                    valpropertybedrooms.Visible = true;
                    valpropertybedrooms.Text = "Unit Type is required!";
                }

                else if ((cmbContactOwner.SelectedIndex == 0) || (cmbContactOwner.SelectedIndex == -1))
                {
                    valOwner.Visible = true;
                    valOwner.Text = "Owner is required!";
                }

                else if ((cmbMasterInfoOwnerAgreement.SelectedIndex == 0) || (cmbMasterInfoOwnerAgreement.SelectedIndex == -1))
                {
                    valcmbAgreementOwner.Visible = true;
                    valcmbAgreementOwner.Text = "Owner On line Agreement is required!";

                }

                else if ((cmbMasterInfoRenterAgreement.SelectedIndex == 0) || (cmbMasterInfoRenterAgreement.SelectedIndex == -1))
                {
                    valCmbAgreementRenter.Visible = true;
                    valCmbAgreementRenter.Text = "Rental Agreement is required!";

                }

                else if ((cmbChargesDeposit.SelectedIndex == 0) || (cmbChargesDeposit.SelectedIndex == -1))
                {
                    valChargesDeposit.Visible = true;
                    valChargesDeposit.Text = "Deposit is required!";
                }

                else if ((cmbChargesExitCleaningFee.SelectedIndex == 0) || (cmbChargesExitCleaningFee.SelectedIndex == -1))
                {
                    valExitCleaningFee.Visible = true;
                    valExitCleaningFee.Text = "Exit Cleaning Fee is required!";
                }

                else
                {
                    propertyManager.UpdateProperty(propertyData);
                    JSSessionHandler.RemoveSessionKey("msg");
                    JSSessionHandler.SetSessionValue("msg", Resources.AdminResource.msgPropertyAdd);
                    Response.Redirect("SearchProperties.aspx");

                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
               
            }

        }
        /// <summary>
        /// Load the Master Informations Details From Page
        /// </summary>
        protected void LoadMasterInformationDataFromPage()
        {
            try
            {

                propertyData.ID = Convert.ToInt64(txtPropertyId.Text);  

                if ((txtMasterInfoPropertyName.Text != null) && (txtMasterInfoPropertyName.Text != string.Empty))
                    propertyData.Name = txtMasterInfoPropertyName.Text;

                propertyData.Description = txtMasterInfoPropertyName.Text;
                propertyData.Exclusive = chkAddPropertyExclusive.Checked;

                if ((cmbMasterInfoDestination.SelectedIndex != 0) && (cmbMasterInfoDestination.SelectedIndex != -1))
                {
                    propertyData.Destination = Convert.ToInt64(cmbMasterInfoDestination.SelectedValue);
                }


                if ((cmbMasterInfoArea.SelectedIndex != 0) && (cmbMasterInfoArea.SelectedIndex != -1))
                {
                    propertyData.SubArea = Convert.ToInt64(cmbMasterInfoArea.SelectedValue);
                }


                if ((cmbMasterInfoLocation.SelectedIndex != 0) && (cmbMasterInfoLocation.SelectedIndex != -1))
                {
                    //  propertyData.Location = Convert.ToInt64(cmbMasterInfoLocation.SelectedValue);
                   
                }
                propertyData.Location = 5;
                propertyData.ForSale = true;

                if ((txtMasterIfnoSale.Text != null) && (txtMasterIfnoSale.Text != string.Empty))
                {
                    propertyData.SaleValue = Convert.ToDouble(txtMasterIfnoSale.Text);
                }

                if ((cmbMasterInfoOwnerAgreement.SelectedIndex != 0) && (cmbMasterInfoOwnerAgreement.SelectedIndex != -1))
                {
                    propertyData.OwnerAgreementTemplateID = Convert.ToInt64(cmbMasterInfoOwnerAgreement.SelectedValue);
                }
                if ((cmbMasterInfoRenterAgreement.SelectedIndex != 0) && (cmbMasterInfoRenterAgreement.SelectedIndex != -1))
                {
                    propertyData.RenterAgreementTemplateID = Convert.ToInt64(cmbMasterInfoRenterAgreement.SelectedValue);
                }

                propertyData.PhoneNumber1 = txtMasterIfnoTelephone1.Text;
                propertyData.PhoneNumber2 = txtMasterIfnoTelephone2.Text;
                propertyData.CommissionPercentage = Convert.ToSingle(txtMasterIfnoCommission.Text);
                propertyData.Active = chkMasterInfoActive.Checked;

                if ((txtChargesDeposit.Text != null) && (txtChargesDeposit.Text != string.Empty))
                    propertyData.Deposit = Convert.ToSingle(txtChargesDeposit.Text);

                if ((txtChargesDailyCleaningFee.Text != null) && (txtChargesDailyCleaningFee.Text != string.Empty))
                    propertyData.DailyCleaningFee = Convert.ToSingle(txtChargesDailyCleaningFee.Text);

                if ((txtChargesExitCleaningFee.Text != null) && (txtChargesExitCleaningFee.Text != string.Empty))
                    propertyData.ExitCleaningFee = Convert.ToSingle(txtChargesExitCleaningFee.Text);

                if ((txtChargesManagementFee.Text != null) && (txtChargesManagementFee.Text != string.Empty))
                    propertyData.ManagementFee = Convert.ToSingle(txtChargesManagementFee.Text);

                propertyData.ManagementFeeType = Convert.ToInt32(cmbChargesPercentageorDollar.SelectedValue);
                propertyData.ManagementFeePeriod = Convert.ToInt32(cmbChargesManagementPer.SelectedValue);
                propertyData.Version = 1;

                //Load the Master Information Details From Page
                LoadMasterInfoAddressDataFromPage();

            }
            catch (Exception ex)
            {
                throw ex;
                //TODO : Implement the Exceptions
            }

        }

        public void loadDetailDataFromPage()
        {
            UserData sessionUser = (UserData)JSSessionHandler.GetSessionValue("UserData");
            PropertyDetailData propertyDetailData = new PropertyDetailData();
            List<PropertyDetailData> listPropertyDetailData = new List<PropertyDetailData>();

            propertyDetailData.SiteDescription = txtDetailsDescription.Text;
            propertyDetailData.KeyCode = txtDetailsKeyCode.Text;
            propertyDetailData.KeyCodeText = txtDetailsKeyCodeDescription.Text;
            propertyDetailData.LockBoxCode = txtDetailsKeyLockCode.Text;
            propertyDetailData.LockBoxCodeText = txtDetailsKeyLockCodeDescription.Text;
            propertyDetailData.DrivingDirections = txtDetailsDrivingDirections.Text;
            propertyDetailData.InternalNotes = txtDetailsInternalNotes.Text;

            if ((txtDetailsSleeps.Text != null) && (txtDetailsSleeps.Text != string.Empty))
                propertyDetailData.NoOfSleeps = Convert.ToInt32(txtDetailsSleeps.Text);

            if ((txtDetailsNofDays.Text != null) && (txtDetailsNofDays.Text != string.Empty))
                propertyDetailData.MinNoOfDays = Convert.ToInt32(txtDetailsNofDays.Text);

            if ((txtDetailsSquareFootage.Text != null) && (txtDetailsSquareFootage.Text != string.Empty))
                propertyDetailData.SquareFootage = Convert.ToSingle(txtDetailsSquareFootage.Text);

            if ((txtDetailsBedRooms.Text != null) && (txtDetailsBedRooms.Text != string.Empty))
                propertyDetailData.NoOfBedrooms = Convert.ToInt32(txtDetailsBedRooms.Text);

            if ((txtDetailsLofts.Text != null) && (txtDetailsLofts.Text != string.Empty))
                propertyDetailData.NoOfLofts = Convert.ToInt32(txtDetailsLofts.Text);

            if ((txtDetailsBathrooms.Text != null) && (txtDetailsBathrooms.Text != string.Empty))
                propertyDetailData.NoOfBaths = Convert.ToSingle(txtDetailsBathrooms.Text);

            if ((txtDetailsStoriesHigh.Text != null) && (txtDetailsStoriesHigh.Text != string.Empty))
                propertyDetailData.NoOfStories = Convert.ToInt32(txtDetailsStoriesHigh.Text);

            propertyDetailData.Community = txtDetailsCommunityName.Text;
            propertyDetailData.Latitude = txtDetailsLatitude.Text;
            propertyDetailData.Longitude = txtDetailsLongitude.Text;

            if (cmbDetailsUnitType.SelectedIndex != 0)
                propertyDetailData.UnitCategoryID = Convert.ToInt32(cmbDetailsUnitType.SelectedValue);

            if (cmbDetailsFeature.SelectedIndex != 0)
                propertyDetailData.PropertyFeatureCategoryID = Convert.ToInt32(cmbDetailsFeature.SelectedValue);

            if (cmbDetailsStyle.SelectedIndex != 0)
                propertyDetailData.StyleCategoryID = Convert.ToInt32(cmbDetailsStyle.SelectedValue);

            if (cmbDetailsHighGarage.SelectedIndex != 0)
                propertyDetailData.Garage = Convert.ToInt32(cmbDetailsHighGarage.SelectedValue);

            propertyDetailData.CreatedOn = new DateTime();
            propertyDetailData.CreatedBy = Convert.ToInt32(sessionUser.Id);
            propertyDetailData.UpdatedOn = new DateTime();
            propertyDetailData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
            listPropertyDetailData.Add(propertyDetailData);
            propertyData.PropertyDetailCollection = listPropertyDetailData;
        }

        //Load the Amenities Details From Page
        public void LoadAmenitiesFromPage()
        {
            try
            {
                UserData sessionUser = (UserData)JSSessionHandler.GetSessionValue("UserData");
                PropertyAmenityData propertyAmenityData = new PropertyAmenityData();
                List<PropertyAmenityData> listPropertyAmenityData = new List<PropertyAmenityData>();
                List<SystemCategoryData> listsystemCategoryAmentiyData = new List<SystemCategoryData>();
                List<long> amenityList = new List<long>();
                int i = 1;

                for (i = 0; i <= Convert.ToInt32(HdnAmentiesCount.Value); i++)
                {
                    if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl25$EditFormControl$chkBusniess" + i.ToString()]) != null)
                    {
                        propertyAmenityData = new PropertyAmenityData();
                        propertyAmenityData.AmenityCategoryID = (Convert.ToInt64(Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl25$EditFormControl$hdnBusniessId" + i.ToString()]));
                        propertyAmenityData.IsAvailable = true;
                        propertyAmenityData.CreatedOn = new DateTime();
                        propertyAmenityData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                        propertyAmenityData.UpdatedOn = new DateTime();
                        propertyAmenityData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                        listPropertyAmenityData.Add(propertyAmenityData);
                    }


                }


                // Entertainment
                for (i = 0; i <= Convert.ToInt32(HdnEntertainmentCount.Value); i++)
                {
                    if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl25$EditFormControl$chkEntertainment" + i.ToString()]) != null)
                    {
                        propertyAmenityData = new PropertyAmenityData();
                        propertyAmenityData.AmenityCategoryID = (Convert.ToInt64(Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl25$EditFormControl$hdnEntertainmentId" + i.ToString()]));
                        propertyAmenityData.IsAvailable = true;
                        propertyAmenityData.CreatedOn = new DateTime();
                        propertyAmenityData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                        propertyAmenityData.UpdatedOn = new DateTime();
                        propertyAmenityData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                        listPropertyAmenityData.Add(propertyAmenityData);

                    }

                }


                // Kitchen
                for (i = 0; i <= Convert.ToInt32(HdnkitchenCount.Value); i++)
                {
                    if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl25$EditFormControl$chkKitchen" + i.ToString()]) != null)
                    {
                        propertyAmenityData = new PropertyAmenityData();
                        propertyAmenityData.AmenityCategoryID = (Convert.ToInt64(Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl25$EditFormControl$hdnKitchenId" + i.ToString()]));
                        propertyAmenityData.IsAvailable = true;
                        propertyAmenityData.CreatedOn = new DateTime();
                        propertyAmenityData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                        propertyAmenityData.UpdatedOn = new DateTime();
                        propertyAmenityData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                        listPropertyAmenityData.Add(propertyAmenityData);

                    }

                }


                //Living
                for (i = 0; i <= Convert.ToInt32(HdnLivingCount.Value); i++)
                {
                    if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl25$EditFormControl$chkLiving" + i.ToString()]) != null)
                    {
                        propertyAmenityData = new PropertyAmenityData();
                        propertyAmenityData.AmenityCategoryID = (Convert.ToInt64(Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl25$EditFormControl$hdnLivingId" + i.ToString()]));
                        propertyAmenityData.IsAvailable = true;
                        propertyAmenityData.CreatedOn = new DateTime();
                        propertyAmenityData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                        propertyAmenityData.UpdatedOn = new DateTime();
                        propertyAmenityData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                        listPropertyAmenityData.Add(propertyAmenityData);

                    }
                }

                propertyData.AmenityDataCollection = listPropertyAmenityData;

            }
            catch (Exception ex)
            {
                throw ex;
            }


        }


        /// <summary>
        ///  Load the Master Information Address Data
        /// </summary>
        /// <returns></returns>    

        public void LoadMasterInfoAddressDataFromPage()
        {
            try
            {
                PropertyAddressData addressData = new PropertyAddressData();
                addressData.AddressLineFirst = txtPropertyAddressOne.Text;
                addressData.AddressLineSecond = txtPropertyAddressTwo.Text;
                addressData.City = txtPropertyAddressCity.Text;
                addressData.StateId = Convert.ToInt32(cmbPropertyAddressState.SelectedValue);
                addressData.CountryId = Convert.ToInt32(cmbPropertyAddressCountry.SelectedValue);
                addressData.ZipCode = txtPropertyAddressZip.Text;
                UserData sessionUser = (UserData)JSSessionHandler.GetSessionValue("UserData");
                addressData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                addressData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                addressData.Active = true;
                propertyData.AddressData = addressData;
            }
            catch (Exception ex)
            {
                throw ex;

            }
        }


        public void loadBedLayoutFromPage()
        {
            propertyData.PropertyRoomsCollection = new List<PropertyRoomsData>();
            propertyData.BedLayoutCollection = new List<BedLayoutData>();           
            UserData sessionUser = (UserData)JSSessionHandler.GetSessionValue("UserData");

            if (aPropertyDataList[0].PropertyRoomsCollection != null)
            {
                for (int i = 0; i < Convert.ToInt32(aPropertyDataList[0].PropertyRoomsCollection.Count); i++)
                {

                    if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtRoomName" + i.ToString()]) != null)
                    {
                        if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtKing" + i.ToString()]) != null)
                        {
                            BedLayoutData bedLayoutData = new BedLayoutData();
                            bedLayoutData.BedCategoryID = 17;
                            bedLayoutData.CreatedOn = new DateTime();
                            bedLayoutData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                            bedLayoutData.UpdatedOn = new DateTime();
                            bedLayoutData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                            propertyData.BedLayoutCollection.Add(bedLayoutData);
                        }

                        if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtQueen" + i.ToString()]) != null)
                        {
                            BedLayoutData bedLayoutData = new BedLayoutData();
                            bedLayoutData.BedCategoryID = 18;
                            bedLayoutData.CreatedOn = new DateTime();
                            bedLayoutData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                            bedLayoutData.UpdatedOn = new DateTime();
                            bedLayoutData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                            propertyData.BedLayoutCollection.Add(bedLayoutData);
                        }


                        if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtDouble" + i.ToString()]) != null)
                        {
                            BedLayoutData bedLayoutData = new BedLayoutData();
                            bedLayoutData.BedCategoryID = 19;
                            bedLayoutData.CreatedOn = new DateTime();
                            bedLayoutData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                            bedLayoutData.UpdatedOn = new DateTime();
                            bedLayoutData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                            propertyData.BedLayoutCollection.Add(bedLayoutData);
                        }

                        if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtSingle" + i.ToString()]) != null)
                        {
                            BedLayoutData bedLayoutData = new BedLayoutData();
                            bedLayoutData.BedCategoryID = 20;
                            bedLayoutData.CreatedOn = new DateTime();
                            bedLayoutData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                            bedLayoutData.UpdatedOn = new DateTime();
                            bedLayoutData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                            propertyData.BedLayoutCollection.Add(bedLayoutData);
                        }


                        if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtSofaBunk" + i.ToString()]) != null)
                        {
                            BedLayoutData bedLayoutData = new BedLayoutData();
                            bedLayoutData.BedCategoryID = 21;
                            bedLayoutData.CreatedOn = new DateTime();
                            bedLayoutData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                            bedLayoutData.UpdatedOn = new DateTime();
                            bedLayoutData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                            propertyData.BedLayoutCollection.Add(bedLayoutData);
                        }

                        if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtSofaBed" + i.ToString()]) != null)
                        {
                            BedLayoutData bedLayoutData = new BedLayoutData();
                            bedLayoutData.BedCategoryID = 22;
                            bedLayoutData.CreatedOn = new DateTime();
                            bedLayoutData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                            bedLayoutData.UpdatedOn = new DateTime();
                            bedLayoutData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                            propertyData.BedLayoutCollection.Add(bedLayoutData);
                        }

                        PropertyRoomsData propertyRoomsData = new PropertyRoomsData();
                        propertyRoomsData.RoomName = (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl53$EditFormControl$txtRoomName" + i.ToString()]);
                        propertyRoomsData.Notes = (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl53$EditFormControl$Notes" + i.ToString()]);

                        propertyRoomsData.CreatedOn = new DateTime();
                        propertyRoomsData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                        propertyRoomsData.UpdatedOn = new DateTime();
                        propertyRoomsData.UpdatedBy = Convert.ToInt32(sessionUser.Id);
                        propertyData.PropertyRoomsCollection.Add(propertyRoomsData);

                    }


                }
            }
        }


        //Load the Contact Details
        public void LoadPropertyCotnactDataFromPage()
        {
            UserData sessionUser = (UserData)JSSessionHandler.GetSessionValue("UserData");
            PropertyContactData propertyContactData = new PropertyContactData();
            List<PropertyContactData> listPropertyContactData = new List<PropertyContactData>();

            if (cmbContactManager.SelectedIndex != 0)
            {
                propertyContactData.ContactTypeID = Convert.ToInt32(JetContactTypes.PropertyManager);
                propertyContactData.ContactID = Convert.ToInt64(cmbContactManager.SelectedValue);
                listPropertyContactData.Add(propertyContactData);

            }

            if (cmbContactOwner.SelectedIndex != 0)
            {
                propertyContactData = new PropertyContactData();
                propertyContactData.ContactID = Convert.ToInt64(cmbContactOwner.SelectedValue);
                propertyContactData.ContactTypeID = Convert.ToInt32(JetContactTypes.Owner);
                listPropertyContactData.Add(propertyContactData);
            }

            if (cmbContactRefferalAgent.SelectedIndex != 0)
            {
                propertyContactData = new PropertyContactData();
                propertyContactData.ContactID = Convert.ToInt64(cmbContactRefferalAgent.SelectedValue);
                propertyContactData.ContactTypeID = Convert.ToInt32(JetContactTypes.PropertyReferralAgent);
                listPropertyContactData.Add(propertyContactData);
            }

            if (cmbContactsCleaningCompany.SelectedIndex != 0)
            {
                propertyContactData = new PropertyContactData();
                propertyContactData.ContactID = Convert.ToInt64(cmbContactsCleaningCompany.SelectedValue);
                propertyContactData.ContactTypeID = Convert.ToInt32(JetContactTypes.CleaningCompany);
                listPropertyContactData.Add(propertyContactData);
            }

            propertyData.ContactCollection = listPropertyContactData;


        }



        /// <summary>
        /// Handling PreRender Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        ///
        protected void griduniversal_PreRender(object sender, System.EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.griduniversal.MasterTableView.Rebind();
            }
        }


        /// <summary>
        /// Loads the data source
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void griduniversal_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {

            IList<ContactData> gridData = new List<ContactData>();
            // gridData = contactManager.GetContact();
            gridData = contactManager.GetContactByTypeId(Convert.ToInt32(JetContactTypes.PropertyVendor));
            this.griduniversal.DataSource = gridData;
        }


        /// <summary>
        /// Grid Edit Data
        /// </summary>
        /// <param name="sourcem"></param>
        /// <param name="e"></param>
        protected void griduniversal_EditCommand(object sourcem, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.EditCommandName)
            {
                GridDataItem item = (GridDataItem)e.Item;
                string contactId = item.GetDataKeyValue("id").ToString();
                JSSessionHandler.SetSessionValue("contactId", contactId);

                switch (item.GetDataKeyValue("ContactTypeID").ToString())
                {
                    case "1":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/Renter.ascx";
                        break;
                    case "2":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/PropertyOwner.ascx";
                        break;
                    case "3":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/PropertyReferralAgent.ascx";
                        break;
                    case "4":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/SalesPerson.ascx";
                        break;
                    case "5":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/CleaningCompany.ascx";
                        break;
                    case "6":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/PropertyVendor.ascx";
                        break;
                    case "7":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/RenterLead.ascx";
                        break;
                    case "8":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/OwnerLead.ascx";
                        break;
                    case "9":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/OutsideVendorLead.ascx";
                        break;
                    case "10":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/OutsideVendorLead.ascx";
                        break;
                    case "11":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/PropertyManager.ascx";
                        break;
                    case "12":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/OutSideVendor.ascx";
                        break;
                    case "13":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/OwnerLead.ascx";
                        break;
                    case "14":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/RenterLead.ascx";
                        break;
                    case "15":
                        griduniversal.MasterTableView.EditFormSettings.UserControlName = "~/UserControl/ReservationRefferalAgent.ascx";
                        break;
                }
            }

        }


        protected void BtnAddITM_Click(object sender, EventArgs e)
        {

            //if (aPropertyDataList[0].PropertyRoomsCollection !=  null )
            //{
                HdnCount.Value = (Convert.ToInt32(aPropertyDataList[0].PropertyRoomsCollection.Count) + 1).ToString();
          //  }
            //else
            //{
            //    int i = 1;
            //    HdnCount.Value = i.ToString();
            //}
        //    DynamicBedLayoutDetails();
            j = Convert.ToInt32(HdnCount.Value);
            DynamicItemDetailsFromPage();
        }
        
        
 
        //DynamicUtilities Details
        protected void BtnUtilitiesAdd_Click(object sender, EventArgs e)
        {
            hdnUtilitiesCount.Value = (Convert.ToInt32(hdnUtilitiesCount.Value) + 1).ToString();
        }


        //DynamicUtilities Details
        protected void BtnAddTax_Click(object sender, EventArgs e)
        {
            HdnTaxCount.Value = (Convert.ToInt32(HdnTaxCount.Value) + 1).ToString();
            DynamicItemTax();
        }

        //Dynamic row Generation for Utilities
        public void DynamicItemTax()
        {
            for (int i = 0; i < Convert.ToInt32(HdnTaxCount.Value); i++)
            {
                TableTax.Attributes.Add("Border", "1");

                HtmlTableRow InRow = new HtmlTableRow();
                InRow.ID = "TableTaxRow" + i.ToString();

                HtmlTableCell Tax = new HtmlTableCell();
                Tax.Align = "left";
                Tax.Attributes.Add("width", "30%");
                RadComboBox taxName = new RadComboBox();
                taxName.ID = "taxName" + i.ToString();
                taxName.Width = 180;
                taxName.Font.Size = 10;
                taxName.CssClass = "dropdownlist";
                string[] taxArray = { "Credit Account", "Jet Living", "Owner" };
                taxName.DataSource = taxArray;
                taxName.DataBind();
                Tax.Controls.Add(taxName);
                InRow.Cells.Add(Tax);


                HtmlTableCell TaxGroup = new HtmlTableCell();
                TaxGroup.Align = "left";
                TaxGroup.Attributes.Add("width", "30%");
                RadComboBox TaxGroupName = new RadComboBox();
                TaxGroupName.ID = "TaxGroupName" + i.ToString();
                TaxGroupName.Width = 180;
                TaxGroupName.Font.Size = 10;
                TaxGroupName.CssClass = "dropdownlist";
                string[] taxGroupArray = { "Mammoth Lakes", "Mammoth Lakes", "Mammoth Lakes" };
                TaxGroupName.DataSource = taxGroupArray;
                TaxGroupName.DataBind();
                TaxGroup.Controls.Add(TaxGroupName);
                InRow.Cells.Add(TaxGroup);


                HtmlTableCell name = new HtmlTableCell();
                name.Align = "left";
                name.Attributes.Add("width", "30%");
                RadComboBox names = new RadComboBox();
                names.ID = "names" + i.ToString();
                names.Width = 180;
                names.Font.Size = 10;
                names.CssClass = "dropdownlist";
                string[] namesArray = { "Rent", "Cleaning", "DailyCleaning" };
                names.DataSource = namesArray;
                names.DataBind();
                name.Controls.Add(names);
                InRow.Cells.Add(name);

                TableTax.Rows.Add(InRow);


            }
        }

        //Load Dynamic Bed Layouts Details
        public void DynamicBedLayoutDetails()
        {
            PropertyRoomsData apropertyRoomsData = new PropertyRoomsData();
            List<PropertyRoomsData> aPropertyRoomsDataList = new List<PropertyRoomsData>();
            BedLayoutData aBedLayoutData = new BedLayoutData();
            IList<BedLayoutData> aBedLayoutDataList = new List<BedLayoutData>();

            PropertyUtilitiesData anPropertyUtilitiesData = new PropertyUtilitiesData();
            IList<PropertyUtilitiesData> anPropertyUtilitiesDataList = new List<PropertyUtilitiesData>();
            int i = 1;

            if (aPropertyDataList[0].PropertyRoomsCollection != null)
            {
                countBedrows = aPropertyDataList[0].PropertyRoomsCollection.Count;

                for (int count = 0; count < aPropertyDataList[0].PropertyRoomsCollection.Count; count++)
                {
                   
                    BedLayout.Attributes.Add("Border", "1");

                    HtmlTableRow InRow = new HtmlTableRow();
                    InRow.ID = "PropertiesRoomsId" + i.ToString();
                    HtmlTableCell PcCell1 = new HtmlTableCell();
                    PcCell1.Align = "left";
                    PcCell1.Attributes.Add("width", "25%");
                    RadTextBox txtRoomName = new RadTextBox();
                    txtRoomName.ID = "txtRoomName" + i.ToString();
                    txtRoomName.Width = 160;
                    txtRoomName.Text = (aPropertyDataList[0].PropertyRoomsCollection[count].RoomName);
                    if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtRoomName" + i.ToString()] != null)
                        txtRoomName.Text = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtRoomName" + i.ToString()].ToString();
                    PcCell1.Controls.Add(txtRoomName);
                    InRow.Cells.Add(PcCell1);


                      //if (aPropertyDataList[0].BedLayoutCollection != null)
                      //{

                      //   for (int bedCount = 0; count < aPropertyDataList[0].BedLayoutCollection.Count; bedCount++)
                      //      {
                            // King
                            HtmlTableCell PcCell2 = new HtmlTableCell();
                            PcCell2.Align = "left";
                            PcCell2.Attributes.Add("width", "10%");
                            RadNumericTextBox txtKing = new RadNumericTextBox();
                            txtKing.ID = "txtKing" + i.ToString();
                            txtKing.Width = 60;
                            txtKing.Font.Size = 10;
                            txtKing.ShowSpinButtons = true;
                            txtKing.NumberFormat.DecimalDigits = 0;
                            txtKing.MinValue = 0;
                            if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtKing" + i.ToString()] != null)
                                txtKing.Text = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtKing" + i.ToString()].ToString();
                            PcCell2.Controls.Add(txtKing);
                            InRow.Cells.Add(PcCell2);

                            // Queen
                            HtmlTableCell PcCell3 = new HtmlTableCell();
                            PcCell3.Align = "left";
                            PcCell3.Attributes.Add("width", "10%");
                            RadNumericTextBox txtQueen = new RadNumericTextBox();
                            txtQueen.ID = "txtQueen" + i.ToString();
                            txtQueen.Width = 60;
                            txtQueen.Font.Size = 10;
                            txtQueen.ShowSpinButtons = true;
                            txtQueen.NumberFormat.DecimalDigits = 0;
                            txtQueen.MinValue = 0;
                            if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtQueen" + i.ToString()] != null)
                                txtQueen.Text = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtQueen" + i.ToString()].ToString();
                            PcCell3.Controls.Add(txtQueen);
                            InRow.Cells.Add(PcCell3);


                            // Double
                            HtmlTableCell PcCell4 = new HtmlTableCell();
                            PcCell4.Align = "left";
                            PcCell4.Attributes.Add("width", "10%");
                            RadNumericTextBox txtDouble = new RadNumericTextBox();
                            txtDouble.ID = "txtDouble" + i.ToString();
                            txtDouble.Width = 60;
                            txtDouble.Font.Size = 10;
                            txtDouble.ShowSpinButtons = true;
                            txtDouble.NumberFormat.DecimalDigits = 0;
                            txtDouble.MinValue = 0;
                            if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtDouble" + i.ToString()] != null)
                                txtDouble.Text = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtDouble" + i.ToString()].ToString();
                            PcCell4.Controls.Add(txtDouble);
                            InRow.Cells.Add(PcCell4);

                            // Single
                            HtmlTableCell PcCell5 = new HtmlTableCell();
                            PcCell5.Align = "left";
                            PcCell5.Attributes.Add("width", "10%");

                            RadNumericTextBox txtSingle = new RadNumericTextBox();
                            txtSingle.ID = "txtSingle" + i.ToString();
                            txtSingle.Width = 60;
                            txtSingle.Font.Size = 10;
                            txtSingle.ShowSpinButtons = true;
                            txtSingle.NumberFormat.DecimalDigits = 0;
                            txtSingle.MinValue = 0;
                            if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtSingle" + i.ToString()] != null)
                                txtSingle.Text = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtSingle" + i.ToString()].ToString();

                            PcCell5.Controls.Add(txtSingle);
                            InRow.Cells.Add(PcCell5);


                            // Bunk
                            HtmlTableCell PcCell6 = new HtmlTableCell();
                            PcCell6.Align = "left";
                            PcCell6.Attributes.Add("width", "10%");
                            RadNumericTextBox txtSofaBunk = new RadNumericTextBox();
                            txtSofaBunk.ID = "txtSofaBunk" + i.ToString();
                            txtSofaBunk.Width = 60;
                            txtSofaBunk.Font.Size = 10;
                            txtSofaBunk.ShowSpinButtons = true;
                            txtSofaBunk.NumberFormat.DecimalDigits = 0;
                            txtSofaBunk.MinValue = 0;
                            if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtSofaBunk" + i.ToString()] != null)
                                txtSofaBunk.Text = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtSofaBunk" + i.ToString()].ToString();
                            PcCell6.Controls.Add(txtSofaBunk);
                            InRow.Cells.Add(PcCell6);


                            // Sofa Bed
                            HtmlTableCell PcCell7 = new HtmlTableCell();
                            PcCell7.Align = "left";
                            PcCell7.Attributes.Add("width", "10%");
                            RadNumericTextBox txtSofaBed = new RadNumericTextBox();
                            txtSofaBed.ID = "txtSofaBed" + i.ToString();
                            txtSofaBed.Width = 60;
                            txtSofaBed.Font.Size = 10;
                            txtSofaBed.ShowSpinButtons = true;
                            txtSofaBed.NumberFormat.DecimalDigits = 0;
                            txtSofaBed.MinValue = 0;
                            if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtSofaBed" + i.ToString()] != null)
                                txtSofaBed.Text = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$txtSofaBed" + i.ToString()].ToString();
                            PcCell7.Controls.Add(txtSofaBed);
                            InRow.Cells.Add(PcCell7);

                   //   }
                   //}

                    //Note
                    HtmlTableCell PcCell8 = new HtmlTableCell();
                    PcCell8.Align = "left";
                    PcCell8.Attributes.Add("width", "100px");
                    TextBox Notes = new TextBox();
                    Notes.AutoPostBack = false;
                    Notes.ID = "Notes" + i.ToString();
                    Notes.CssClass = "bodytextrequired";
                    Notes.Text = (aPropertyDataList[0].PropertyRoomsCollection[count].Notes);  
                    Notes.Width = 120;
                    if (Request["tl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$Notes" + i.ToString()] != null)
                        Notes.Text = Request["tl00$contentMaster$gridPropertySearch$ctl00$ctl13$EditFormControl$Notes" + i.ToString()].ToString();

                    PcCell8.Controls.Add(Notes);
                    InRow.Cells.Add(PcCell8);



                    BedLayout.Rows.Add(InRow);

                    i++;
                }
               
            }
           
        }





        // Add Bed Layouts
        public void DynamicItemDetailsFromPage()
        {
            for (int i = j; i <= Convert.ToInt32(HdnCount.Value); i++)
            {
                BedLayout.Attributes.Add("Border", "1");

                HtmlTableRow InRow = new HtmlTableRow();
                InRow.ID = "IncentiveDetailsId" + i.ToString();
                HtmlTableCell PcCell1 = new HtmlTableCell();
                PcCell1.Align = "left";
                PcCell1.Attributes.Add("width", "25%");
                RadTextBox txtRoomName = new RadTextBox();
                txtRoomName.ID = "txtRoomName" + i.ToString();
                txtRoomName.Width = 160;
                if (Request["ctl00$contentMaster$txtRoomName" + i.ToString()] != null)
                    txtRoomName.Text = Request["ctl00$contentMaster$txtRoomName" + i.ToString()].ToString();
                PcCell1.Controls.Add(txtRoomName);
                InRow.Cells.Add(PcCell1);

                // King
                HtmlTableCell PcCell2 = new HtmlTableCell();
                PcCell2.Align = "left";
                PcCell2.Attributes.Add("width", "10%");
                RadNumericTextBox txtKing = new RadNumericTextBox();
                txtKing.ID = "txtKing" + i.ToString();
                txtKing.Width = 60;
                txtKing.Font.Size = 10;
                txtKing.ShowSpinButtons = true;
                txtKing.NumberFormat.DecimalDigits = 0;
                txtKing.MinValue = 0;
                if (Request["ctl00$contentMaster$txtKing" + i.ToString()] != null)
                    txtKing.Text = Request["ctl00$contentMaster$txtKing" + i.ToString()].ToString();
                PcCell2.Controls.Add(txtKing);
                InRow.Cells.Add(PcCell2);

                // Queen
                HtmlTableCell PcCell3 = new HtmlTableCell();
                PcCell3.Align = "left";
                PcCell3.Attributes.Add("width", "10%");
                RadNumericTextBox txtQueen = new RadNumericTextBox();
                txtQueen.ID = "txtQueen" + i.ToString();
                txtQueen.Width = 60;
                txtQueen.Font.Size = 10;
                txtQueen.ShowSpinButtons = true;
                txtQueen.NumberFormat.DecimalDigits = 0;
                txtQueen.MinValue = 0;
                if (Request["ctl00$contentMaster$txtQueen" + i.ToString()] != null)
                    txtQueen.Text = Request["ctl00$contentMaster$txtQueen" + i.ToString()].ToString();
                PcCell3.Controls.Add(txtQueen);
                InRow.Cells.Add(PcCell3);


                // Double
                HtmlTableCell PcCell4 = new HtmlTableCell();
                PcCell4.Align = "left";
                PcCell4.Attributes.Add("width", "10%");
                RadNumericTextBox txtDouble = new RadNumericTextBox();
                txtDouble.ID = "txtDouble" + i.ToString();
                txtDouble.Width = 60;
                txtDouble.Font.Size = 10;
                txtDouble.ShowSpinButtons = true;
                txtDouble.NumberFormat.DecimalDigits = 0;
                txtDouble.MinValue = 0;
                if (Request["ctl00$contentMaster$txtDouble" + i.ToString()] != null)
                    txtDouble.Text = Request["ctl00$contentMaster$txtDouble" + i.ToString()].ToString();
                PcCell4.Controls.Add(txtDouble);
                InRow.Cells.Add(PcCell4);

                // Single
                HtmlTableCell PcCell5 = new HtmlTableCell();
                PcCell5.Align = "left";
                PcCell5.Attributes.Add("width", "10%");

                RadNumericTextBox txtSingle = new RadNumericTextBox();
                txtSingle.ID = "txtSingle" + i.ToString();
                txtSingle.Width = 60;
                txtSingle.Font.Size = 10;
                txtSingle.ShowSpinButtons = true;
                txtSingle.NumberFormat.DecimalDigits = 0;
                txtSingle.MinValue = 0;
                if (Request["ctl00$contentMaster$txtSingle" + i.ToString()] != null)
                    txtSingle.Text = Request["ctl00$contentMaster$txtSingle" + i.ToString()].ToString();

                PcCell5.Controls.Add(txtSingle);
                InRow.Cells.Add(PcCell5);


                // Bunk
                HtmlTableCell PcCell6 = new HtmlTableCell();
                PcCell6.Align = "left";
                PcCell6.Attributes.Add("width", "10%");
                RadNumericTextBox txtSofaBunk = new RadNumericTextBox();
                txtSofaBunk.ID = "txtSofaBunk" + i.ToString();
                txtSofaBunk.Width = 60;
                txtSofaBunk.Font.Size = 10;
                txtSofaBunk.ShowSpinButtons = true;
                txtSofaBunk.NumberFormat.DecimalDigits = 0;
                txtSofaBunk.MinValue = 0;
                if (Request["ctl00$contentMaster$txtSofaBunk" + i.ToString()] != null)
                    txtSofaBunk.Text = Request["ctl00$contentMaster$txtSofaBunk" + i.ToString()].ToString();
                PcCell6.Controls.Add(txtSofaBunk);
                InRow.Cells.Add(PcCell6);


                // Sofa Bed
                HtmlTableCell PcCell7 = new HtmlTableCell();
                PcCell7.Align = "left";
                PcCell7.Attributes.Add("width", "10%");
                RadNumericTextBox txtSofaBed = new RadNumericTextBox();
                txtSofaBed.ID = "txtSofaBed" + i.ToString();
                txtSofaBed.Width = 60;
                txtSofaBed.Font.Size = 10;
                txtSofaBed.ShowSpinButtons = true;
                txtSofaBed.NumberFormat.DecimalDigits = 0;
                txtSofaBed.MinValue = 0;
                if (Request["ctl00$contentMaster$txtSofaBed" + i.ToString()] != null)
                    txtSofaBed.Text = Request["ctl00$contentMaster$txtSofaBed" + i.ToString()].ToString();
                PcCell7.Controls.Add(txtSofaBed);
                InRow.Cells.Add(PcCell7);


                //Note
                HtmlTableCell PcCell8 = new HtmlTableCell();
                PcCell8.Align = "left";
                PcCell8.Attributes.Add("width", "100px");
                TextBox Notes = new TextBox();
                Notes.AutoPostBack = false;
                Notes.ID = "Notes" + i.ToString();
                Notes.CssClass = "bodytextrequired";
                Notes.Width = 120;
                if (Request["ctl00$contentMaster$Notes" + i.ToString()] != null)
                    Notes.Text = Request["ctl00$contentMaster$Notes" + i.ToString()].ToString();

                PcCell8.Controls.Add(Notes);
                InRow.Cells.Add(PcCell8);

                BedLayout.Rows.Add(InRow);

            }
        }

 
        #region "Aminities Regional"

     
        public void LoadUtilitiesDetailsFromPage()
        {


            UserData sessionUser = (UserData)JSSessionHandler.GetSessionValue("UserData");
            PropertyUtilitiesData propertyUtilitiesData = new PropertyUtilitiesData();
            List<PropertyUtilitiesData> listPropertyUtilitiesData = new List<PropertyUtilitiesData>();

            for (int i = 1; i <= Convert.ToInt32(hdnUtilitiesCount.Value); i++)
            {

                if ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesAccount" + i.ToString()] != null) && ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesTelephone" + i]).ToString() != null))
                {
                    propertyUtilitiesData = new PropertyUtilitiesData();

                    propertyUtilitiesData.UtilityCategoryID = (Convert.ToInt64(Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$hdnUtilitiesDetailsId" + i.ToString()]));
                    propertyUtilitiesData.AccountNumber = (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesAccount" + i.ToString()]);
                    propertyUtilitiesData.TelephoneNumber = ((Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesTelephone" + i]).ToString());

                    propertyUtilitiesData.CreatedOn = new DateTime();
                    propertyUtilitiesData.CreatedBy = Convert.ToInt32(sessionUser.Id);
                    propertyUtilitiesData.UpdatedOn = new DateTime();
                    propertyUtilitiesData.UpdatedBy = Convert.ToInt32(sessionUser.Id);

                    listPropertyUtilitiesData.Add(propertyUtilitiesData);
                }

            }
            propertyData.PropertyUtilitiesCollection = listPropertyUtilitiesData;
        }
    

        #endregion



        #region "Retrieve the Data for DataBase()

        /// <summary>
        /// Retrieve Master Informations Details From DB
        /// </summary>       
        public void LoadMasterInformationFromDB()
        {
            foreach (PropertyData propertyData in aPropertyDataList)
            {

                txtMasterInfoPropertyName.Text = propertyData.Name;                
                chkAddPropertyExclusive.Checked=propertyData.Exclusive;                  
                cmbMasterInfoDestination.SelectedValue = propertyData.Destination.ToString();

                if((propertyData.Destination.ToString() !=null ) && (propertyData.Destination.ToString() !=string.Empty))
                {
                    if (cmbMasterInfoArea.SelectedIndex != 0)
                    {
                        IList<AreaData> subAreaData = new List<AreaData>();
                        subAreaData = areaManager.GetSubArea(propertyData.Destination);
                        cmbMasterInfoArea.DataSource = subAreaData;
                        cmbMasterInfoArea.DataTextField = "Name";
                        cmbMasterInfoArea.DataValueField = "ID";
                        cmbMasterInfoArea.DataBind();

                        RadComboBoxItem cmbSubArea = new RadComboBoxItem();
                        cmbSubArea.Text = " ";
                        cmbMasterInfoArea.Items.Insert(0, cmbSubArea);
                    }
                }

              
                cmbMasterInfoArea.SelectedValue = Convert.ToString(propertyData.SubArea);

                if ((propertyData.SubArea.ToString() != null) && (propertyData.SubArea.ToString() != string.Empty))
                {
                    if (cmbMasterInfoLocation.SelectedIndex != 0)  
                    {
                        IList<AreaData> locationData = new List<AreaData>();
                        locationData = areaManager.GetChildArea(propertyData.SubArea);
                        cmbMasterInfoLocation.DataSource = locationData;
                        cmbMasterInfoLocation.DataTextField = "Name";
                        cmbMasterInfoLocation.DataValueField = "ID";
                        cmbMasterInfoLocation.DataBind();

                        RadComboBoxItem cmbLocation = new RadComboBoxItem();
                        cmbLocation.Text = " ";
                        cmbMasterInfoLocation.Items.Insert(0, cmbLocation);
                    }
                }
                cmbGeneralInfoLocation.SelectedValue = Convert.ToString(propertyData.Location);
                cmbMasterInfoOwnerAgreement.SelectedValue = propertyData.OwnerAgreementTemplateID.ToString();
                cmbMasterInfoRenterAgreement.SelectedValue = propertyData.RenterAgreementTemplateID.ToString();
                txtMasterIfnoSale.Text = propertyData.SaleValue.ToString();
                txtMasterIfnoTelephone1.Text=propertyData.PhoneNumber1;
                txtMasterIfnoTelephone2.Text=propertyData.PhoneNumber2;
                txtMasterIfnoCommission.Text=Convert.ToString(propertyData.CommissionPercentage);
                chkMasterInfoActive.Checked=propertyData.Active;
                txtChargesDeposit.Text=propertyData.Deposit.ToString();
                txtChargesDailyCleaningFee.Text=propertyData.DailyCleaningFee.ToString();
                txtChargesExitCleaningFee.Text=propertyData.ExitCleaningFee.ToString();
                txtChargesManagementFee.Text=propertyData.ManagementFee.ToString();
                cmbChargesPercentageorDollar.SelectedValue=propertyData.ManagementFeeType.ToString();
                cmbChargesManagementPer.SelectedValue = propertyData.ManagementFeePeriod.ToString();

             
                if (propertyData.AddressData != null)
                {
                    txtPropertyAddressOne.Text = propertyData.AddressData.AddressLineFirst;
                    txtPropertyAddressTwo.Text = propertyData.AddressData.AddressLineSecond;
                    txtPropertyAddressCity.Text = propertyData.AddressData.City;                     
                    cmbPropertyAddressState.SelectedValue = Convert.ToString(propertyData.AddressData.StateId);
                    cmbPropertyAddressCountry.SelectedValue = Convert.ToString(propertyData.AddressData.CountryId);
                    txtPropertyAddressZip.Text = propertyData.AddressData.ZipCode;
                }
              

            }


        }

        /// <summary>
        /// Load the Property Detail Tab informations From DB
        /// </summary>
        public void LoadPropertyDetailsFromDB()
        {
            if (aPropertyDataList[0].PropertyDetailCollection != null)
            {   

                for (int count = 0; count < aPropertyDataList[0].PropertyDetailCollection.Count; count++)
                {
                    
                     txtDetailsDescription.Text = Convert.ToString(aPropertyDataList[0].PropertyDetailCollection[count].SiteDescription);
                     txtDetailsKeyCode.Text = (aPropertyDataList[0].PropertyDetailCollection[count].KeyCode);
                     txtDetailsKeyCodeDescription.Text = (aPropertyDataList[0].PropertyDetailCollection[count].KeyCodeText);
                     txtDetailsKeyLockCode.Text = (aPropertyDataList[0].PropertyDetailCollection[count].LockBoxCode);
                     txtDetailsKeyLockCodeDescription.Text = (aPropertyDataList[0].PropertyDetailCollection[count].LockBoxCodeText);                                                                           
                     txtDetailsDrivingDirections.Text  = (aPropertyDataList[0].PropertyDetailCollection[count].DrivingDirections);
                     txtDetailsInternalNotes.Text = (aPropertyDataList[0].PropertyDetailCollection[count].InternalNotes);
                     txtDetailsSleeps.Text = (aPropertyDataList[0].PropertyDetailCollection[count].NoOfSleeps).ToString();
                     txtDetailsNofDays.Text = (aPropertyDataList[0].PropertyDetailCollection[count].MinNoOfDays).ToString();
                     txtDetailsSquareFootage.Text = (aPropertyDataList[0].PropertyDetailCollection[count].SquareFootage).ToString();                                                                                                                                                                                                    
                     txtDetailsBedRooms.Text = (aPropertyDataList[0].PropertyDetailCollection[count].NoOfBedrooms).ToString();                                                                                                                                                                                                   
                     txtDetailsLofts.Text  = (aPropertyDataList[0].PropertyDetailCollection[count].NoOfLofts).ToString();
                     txtDetailsBathrooms.Text = (aPropertyDataList[0].PropertyDetailCollection[count].NoOfBaths).ToString();
                     txtDetailsStoriesHigh.Text = (aPropertyDataList[0].PropertyDetailCollection[count].NoOfStories).ToString();
                     txtDetailsCommunityName.Text = (aPropertyDataList[0].PropertyDetailCollection[count].Community).ToString();
                     txtDetailsLatitude.Text = (aPropertyDataList[0].PropertyDetailCollection[count].Latitude).ToString();
                     txtDetailsLongitude.Text = (aPropertyDataList[0].PropertyDetailCollection[count].Longitude).ToString();
                     cmbDetailsHighGarage.SelectedValue = Convert.ToString(aPropertyDataList[0].PropertyDetailCollection[count].Garage);
                     cmbDetailsUnitType.SelectedValue = Convert.ToString(aPropertyDataList[0].PropertyDetailCollection[count].UnitCategoryID);
                     cmbDetailsFeature.SelectedValue = (aPropertyDataList[0].PropertyDetailCollection[count].PropertyFeatureCategoryID).ToString();
                     cmbDetailsStyle.SelectedValue = (aPropertyDataList[0].PropertyDetailCollection[count].StyleCategoryID).ToString();
                }
            }
                     
          }

        //Load the Contact Details FromDataBase
        public void LoadContactDetailsFromDB()
        {
            if (aPropertyDataList[0].ContactCollection  != null)
            {

                for (int count = 0; count < aPropertyDataList[0].ContactCollection.Count; count++)
                {
                    long ContactType;
                    ContactType = (aPropertyDataList[0].ContactCollection[count].ContactTypeID);

                    if (ContactType == 11)
                    {
                        cmbContactManager.SelectedValue = Convert.ToString(aPropertyDataList[0].ContactCollection[count].ContactID);
                    }
                    else if (ContactType == 2)
                    {                         
                        cmbContactOwner.SelectedValue = Convert.ToString(aPropertyDataList[0].ContactCollection[count].ContactID);
                    }
                    else if (ContactType == 3)
                    {                
                        cmbContactRefferalAgent.SelectedValue = Convert.ToString(aPropertyDataList[0].ContactCollection[count].ContactID);
                    }
                    else
                    {
                        cmbContactsCleaningCompany.SelectedValue  = Convert.ToString(aPropertyDataList[0].ContactCollection[count].ContactID);
                    }
                    
                 }

             }
         }
        

        /// <summary>
        /// Load Utilities Details From DB
        /// </summary>
        public void LoadPropertyUtilitiesDetailFromDB()
        {
            IList<long> UtilitiesData = new List<long>();

            PropertyUtilitiesData anPropertyUtilitiesData = new PropertyUtilitiesData();
            IList<PropertyUtilitiesData> anPropertyUtilitiesDataList = new List<PropertyUtilitiesData>();

             List<SystemCategoryData> systemCategoryData = new List<SystemCategoryData>();
            systemCategoryData = categoryManager.GetAllUtilities();

             int i=1;
            foreach (SystemCategoryData data in systemCategoryData)
            {

                 Label lblutilities = new Label();
                lblutilities.Text = data.Name;
                lblutilities.ID = "lblutilities" + i.ToString();
                lblutilities.Width = 200;
                HiddenField hdnutilities = new HiddenField();
                HdnUtilities.ID = "hdnutilities" + i.ToString();


                HiddenField hdnUtilitiesDetailsId = new HiddenField();
                hdnUtilitiesDetailsId.Value = data.Id.ToString();
                hdnUtilitiesDetailsId.ID = "hdnUtilitiesDetailsId" + i.ToString();
                if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$hdnUtilitiesDetailsId" + i.ToString()] != null)
                    hdnUtilitiesDetailsId.Value = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$hdnUtilitiesDetailsId" + i.ToString()].ToString();


                RadTextBox txtutilitiesAccount = new RadTextBox();
                txtutilitiesAccount.ID = "txtutilitiesAccount" + i.ToString();
                txtutilitiesAccount.Width = 150;
                if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesAccount" + i.ToString()] != null)
                    txtutilitiesAccount.Text = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesAccount" + i.ToString()].ToString();

                RadTextBox txtutilitiesTelephone = new RadTextBox();
                txtutilitiesTelephone.ID = "txtutilitiesTelephone" + i.ToString();
                txtutilitiesTelephone.Width = 150;
                if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesTelephone" + i.ToString()] != null)
                    txtutilitiesTelephone.Text = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesTelephone" + i.ToString()].ToString();

                pnlUtilities.Controls.Add(lblutilities);
                pnlUtilities.Controls.Add(hdnutilities);

                pnlUtilities.Controls.Add(hdnUtilitiesDetailsId);
                pnlUtilities.Controls.Add(txtutilitiesAccount);
                pnlUtilities.Controls.Add(txtutilitiesTelephone);
                pnlUtilities.Controls.Add(new LiteralControl("<br>"));              
                hdnUtilitiesCount.Value = i.ToString();
                



             if (aPropertyDataList[0].PropertyUtilitiesCollection != null)
              {
                for (int count = 0; count < aPropertyDataList[0].PropertyUtilitiesCollection.Count; count++)
                {

                    anPropertyUtilitiesData.UtilityCategoryID = Convert.ToInt64(aPropertyDataList[0].PropertyUtilitiesCollection[count].UtilityCategoryID);
                    anPropertyUtilitiesData.AccountNumber = (aPropertyDataList[0].PropertyUtilitiesCollection[count].AccountNumber).ToString();
                    anPropertyUtilitiesData.TelephoneNumber = (aPropertyDataList[0].PropertyUtilitiesCollection[count].AccountNumber).ToString();
                    anPropertyUtilitiesDataList.Add(anPropertyUtilitiesData);

                    long UtilitiesID = Convert.ToInt64(aPropertyDataList[0].PropertyUtilitiesCollection[count].UtilityCategoryID);

                    if (UtilitiesID == (Convert.ToInt64(hdnUtilitiesDetailsId.Value)))                  
                    {
                        txtutilitiesAccount.Text=(aPropertyDataList[0].PropertyUtilitiesCollection[count].AccountNumber).ToString();
                        txtutilitiesTelephone.Text= (aPropertyDataList[0].PropertyUtilitiesCollection[count].TelephoneNumber).ToString();                        
                        
                    }

                }
            }

             i++;
        }
        }
        

        /// <summary>
        /// Load AmentitiesDetails From DataBase
        /// </summary>
        public void LoadPropertyAmenitiesDetailFromDB()
        {

            // Load the Busniess Details
            List<SystemCategoryData> systemCategoryData = new List<SystemCategoryData>();
            systemCategoryData = categoryManager.GetAllBusiness();

            pnlBusniess.Controls.Add(new LiteralControl("<br>"));
            int i = 1;
            foreach (SystemCategoryData data in systemCategoryData)
            {
                CheckBox chkBusniess = new CheckBox();
                chkBusniess.Text = data.Name;
                chkBusniess.ID = "chkBusniess" + i.ToString();
                chkBusniess.Width = 215;
                chkBusniess.Height = 50;

                HiddenField hdnBusniessId = new HiddenField();
                hdnBusniessId.Value = data.Id.ToString();
                hdnBusniessId.ID = "hdnBusniessId" + i.ToString();

                
                HiddenField hdnBusniessAmenityCategoryID = new HiddenField();
                hdnBusniessAmenityCategoryID.Value = data.CategoryTypeId.ToString();
                hdnBusniessAmenityCategoryID.ID = "hdnBusniessAmenityCategoryID" + i.ToString();


                pnlBusniess.Controls.Add(chkBusniess);
                pnlBusniess.Controls.Add(hdnBusniessId);
                HdnAmentiesCount.Value = i.ToString();

                if (aPropertyDataList[0].AmenityDataCollection != null)
                {
                    for (int count = 0; count < aPropertyDataList[0].AmenityDataCollection.Count; count++)
                    {
                        long amenityCategoryID = Convert.ToInt64(aPropertyDataList[0].AmenityDataCollection[count].AmenityCategoryID);
                      
                        
                        if (amenityCategoryID == (Convert.ToInt64((hdnBusniessId.Value))))                          
                        {
                            chkBusniess.Checked = true;

                        }
                    }

                }
                i++;
            }


            //Load the Entertainment Details
            List<SystemCategoryData> systemCategoryEntertainmentData = new List<SystemCategoryData>();
            systemCategoryEntertainmentData = categoryManager.GetAllEntertainment();

            pnlEntertainment.Controls.Add(new LiteralControl("<br>"));
            int e = 1;
            foreach (SystemCategoryData entertainmentData in systemCategoryEntertainmentData)
            {
                CheckBox chkEntertainment = new CheckBox();
                chkEntertainment.Text = entertainmentData.Name;
                chkEntertainment.ID = "chkEntertainment" + e.ToString();
                chkEntertainment.Width = 200;
                chkEntertainment.Height = 50;



                HiddenField hdnEntertainmentId = new HiddenField();
                hdnEntertainmentId.Value = entertainmentData.Id.ToString();
                hdnEntertainmentId.ID = "hdnEntertainmentId" + e.ToString();

                pnlEntertainment.Controls.Add(chkEntertainment);
                pnlEntertainment.Controls.Add(hdnEntertainmentId);
                HdnEntertainmentCount.Value = e.ToString();
                

                if (aPropertyDataList[0].AmenityDataCollection != null)
                {
                    for (int count = 0; count < aPropertyDataList[0].AmenityDataCollection.Count; count++)
                    {
                        long amenityCategoryID = Convert.ToInt64(aPropertyDataList[0].AmenityDataCollection[count].AmenityCategoryID);


                        if (amenityCategoryID == (Convert.ToInt64((hdnEntertainmentId.Value))))
                        {
                            chkEntertainment.Checked = true;

                        }
                    }

                }

                e++;
            }


            //Load the Kitchen Details
            List<SystemCategoryData> systemCategoryKitchenData = new List<SystemCategoryData>();
            systemCategoryKitchenData = categoryManager.GetAllKitchen();

            pnlKitchen.Controls.Add(new LiteralControl("<br>"));
            int k = 1;
            foreach (SystemCategoryData kitchenData in systemCategoryKitchenData)
            {
                CheckBox chkKitchen = new CheckBox();
                chkKitchen.Text = kitchenData.Name;
                chkKitchen.ID = "chkKitchen" + k.ToString();
                chkKitchen.Width = 200;
                chkKitchen.Height = 50;

                HiddenField hdnKitchenId = new HiddenField();
                hdnKitchenId.Value = kitchenData.Id.ToString();
                hdnKitchenId.ID = "hdnKitchenId" + k.ToString();

                pnlKitchen.Controls.Add(chkKitchen);
                pnlKitchen.Controls.Add(hdnKitchenId);
                HdnkitchenCount.Value = k.ToString();

                if (aPropertyDataList[0].AmenityDataCollection != null)
                {
                    for (int count = 0; count < aPropertyDataList[0].AmenityDataCollection.Count; count++)
                    {
                        long amenityCategoryID = Convert.ToInt64(aPropertyDataList[0].AmenityDataCollection[count].AmenityCategoryID);


                        if (amenityCategoryID == (Convert.ToInt64((hdnKitchenId.Value))))
                        {
                            chkKitchen.Checked = true;

                        }
                    }

                }
                k++;
            }



            //Load the Living Details
            List<SystemCategoryData> systemCategoryLivingData = new List<SystemCategoryData>();
            systemCategoryLivingData = categoryManager.GetAllLiving();

            pnlLiving.Controls.Add(new LiteralControl("<br>"));
            int l = 1;
            foreach (SystemCategoryData livingData in systemCategoryLivingData)
            {
                CheckBox chkLiving = new CheckBox();
                chkLiving.Text = livingData.Name;
                chkLiving.ID = "chkLiving" + l.ToString();
                chkLiving.Width = 200;
                chkLiving.Height = 50;

                HiddenField hdnLivingId = new HiddenField();
                hdnLivingId.Value = livingData.Id.ToString();
                hdnLivingId.ID = "hdnLivingId" + l.ToString();               
                pnlLiving.Controls.Add(chkLiving);
                pnlLiving.Controls.Add(hdnLivingId);
                HdnLivingCount.Value = l.ToString();

                if (aPropertyDataList[0].AmenityDataCollection != null)
                {
                    for (int count = 0; count < aPropertyDataList[0].AmenityDataCollection.Count; count++)
                    {
                        long amenityCategoryID = Convert.ToInt64(aPropertyDataList[0].AmenityDataCollection[count].AmenityCategoryID);


                        if (amenityCategoryID == (Convert.ToInt64((hdnLivingId.Value))))
                        {
                            chkLiving.Checked = true;

                        }
                    }

                }

                l++;              

            }

        }
              #endregion

        public void LoadUtilitiesDetailsFromDB()
        {
            // Load the Busniess Details
            List<SystemCategoryData> systemCategoryData = new List<SystemCategoryData>();
            systemCategoryData = categoryManager.GetAllUtilities();

            pnlUtilities.Controls.Add(new LiteralControl("<br>"));
            int i = 1;
            foreach (SystemCategoryData data in systemCategoryData)
            {
                Label lblutilities = new Label();
                lblutilities.Text = data.Name;
                lblutilities.ID = "lblutilities" + i.ToString();
                lblutilities.Width = 200;
                HiddenField hdnutilities = new HiddenField();
                HdnUtilities.ID = "hdnutilities" + i.ToString();


                HiddenField hdnUtilitiesDetailsId = new HiddenField();
                hdnUtilitiesDetailsId.Value = data.Id.ToString();
                hdnUtilitiesDetailsId.ID = "hdnUtilitiesDetailsId" + i.ToString();
                if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$hdnUtilitiesDetailsId" + i.ToString()] != null)
                    hdnUtilitiesDetailsId.Value = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$hdnUtilitiesDetailsId" + i.ToString()].ToString();



                //   RadTextBox txtutilitiesAccount = new RadTextBox();
                RadTextBox txtutilitiesAccount = new RadTextBox();
                txtutilitiesAccount.ID = "txtutilitiesAccount" + i.ToString();
                txtutilitiesAccount.Width = 150;
                if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesAccount" + i.ToString()] != null)
                    txtutilitiesAccount.Text = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesAccount" + i.ToString()].ToString();

                RadTextBox txtutilitiesTelephone = new RadTextBox();
                txtutilitiesTelephone.ID = "txtutilitiesTelephone" + i.ToString();
                txtutilitiesTelephone.Width = 150;
                if (Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesTelephone" + i.ToString()] != null)
                    txtutilitiesTelephone.Text = Request["ctl00$contentMaster$gridPropertySearch$ctl00$ctl17$EditFormControl$txtutilitiesTelephone" + i.ToString()].ToString();

                pnlUtilities.Controls.Add(lblutilities);
                pnlUtilities.Controls.Add(hdnutilities);

                pnlUtilities.Controls.Add(hdnUtilitiesDetailsId);
                pnlUtilities.Controls.Add(txtutilitiesAccount);
                pnlUtilities.Controls.Add(txtutilitiesTelephone);
                pnlUtilities.Controls.Add(new LiteralControl("<br>"));             
                hdnUtilitiesCount.Value = i.ToString();
                i++; ;

            }


        }

    }


}








1 Answer, 1 is accepted

Sort by
0
Bruno
Top achievements
Rank 2
answered on 02 Apr 2009, 03:08 PM
Actually you should not rely on hardcoded control uniqueids in such way. You should use current namingcontainer's FindControl method passing the control's id order to retrive the control's instance.

If you want to dynamically create controls you should basically recreate them in load event in the same order and with ids in which they have been added initially.
Tags
Grid
Asked by
mani
Top achievements
Rank 1
Answers by
Bruno
Top achievements
Rank 2
Share this question
or