}//end getAllCities

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtTargetVal.Text) && !string.IsNullOrWhiteSpace(txtTargetVal.Text))
            {
                lblWarning.Visible = false;
                string      searchValue = txtTargetVal.Text;
                string      searchOp    = ddlSearchOp.SelectedValue;
                string      searchType  = ddlSearchType.SelectedValue;
                WebRequest  request     = WebRequest.Create(webApiUrl + searchType + "?targetValue=" + searchValue + "&op=" + searchOp);
                WebResponse response    = request.GetResponse();

                // Read the data from the Web Response, which requires working with streams.
                Stream       theDataStream = response.GetResponseStream();
                StreamReader reader        = new StreamReader(theDataStream);
                String       data          = reader.ReadToEnd();

                reader.Close();
                response.Close();

                // Deserialize a JSON string that contains an array of JSON objects into an Array of Team objects.
                JavaScriptSerializer js       = new JavaScriptSerializer();
                List <City>          CityList = js.Deserialize <List <City> >(data);
                if (CityList != null)
                {
                    if (CityList.Count > 0)
                    {
                        container.InnerHtml = "";
                        container.InnerHtml = CityGUI.DisplayCities(CityList);
                    }
                    else
                    {
                        lblWarning.Visible = true;
                        lblWarning.Text    = "No Records Found";
                    }
                }
                else
                {
                    lblWarning.Visible = true;
                    lblWarning.Text    = "No Records Found";
                }
            } //end if
        }     //end btn search
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (ValidateTextBoxes())
            {
                lblWarning.Visible = false;
                DisplayMode();

                City City = new City();
                City.Id                    = txtId.Text;
                City.BurglaryRate          = decimal.Parse(txtBurgRate.Text);
                City.FemaleMedianAge       = int.Parse(txtFemaleMedAge.Text);
                City.MaleMedianAge         = int.Parse(txtMaleMedAge.Text);
                City.MedianHouseIncome     = decimal.Parse(txtMedHI.Text);
                City.MotorVehicleTheftRate = decimal.Parse(txtVehTheftRate.Text);
                City.Name                  = txtName.Text;
                City.PercOwners            = decimal.Parse(txtPercOwn.Text);
                City.PercRenters           = decimal.Parse(txtRent.Text);
                City.Population            = int.Parse(txtPop.Text);
                City.State                 = txtState.Text;
                City.UnemploymentRate      = decimal.Parse(txtUnemploymentRate.Text);

                // Serialize a Customer object into a JSON string.
                JavaScriptSerializer js = new JavaScriptSerializer();
                String jsonCity         = js.Serialize(City);

                if (!string.IsNullOrEmpty(txtId.Text))
                {
                    try

                    {
                        WebRequest request = WebRequest.Create(webApiUrl + "Update");
                        request.Method        = "POST";
                        request.ContentLength = jsonCity.Length;
                        request.ContentType   = "application/json";

                        // Write the JSON data to the Web Request
                        StreamWriter writer = new StreamWriter(request.GetRequestStream());
                        writer.Write(jsonCity);
                        writer.Flush();
                        writer.Close();

                        // Read the data from the Web Response, which requires working with streams.
                        WebResponse  response      = request.GetResponse();
                        Stream       theDataStream = response.GetResponseStream();
                        StreamReader reader        = new StreamReader(theDataStream);
                        String       data          = reader.ReadToEnd();

                        reader.Close();
                        response.Close();

                        if (data == "false")
                        {
                            lblWarning.Visible = true;
                            lblWarning.Text    = "Record not Updated";
                        }//end if
                        else
                        {
                            lblWarning.Visible  = true;
                            lblWarning.Text     = "Record Updated";
                            container.InnerHtml = "";
                            container.InnerHtml = CityGUI.DisplayCities(getAllCities());
                        }//end else
                    }
                    catch (Exception ex)
                    {
                        lblWarning.Text = "Error: " + ex.Message;
                    }
                }//end if
                else
                {
                    try

                    {
                        WebRequest request = WebRequest.Create(webApiUrl + "Add");
                        request.Method        = "POST";
                        request.ContentLength = jsonCity.Length;
                        request.ContentType   = "application/json";

                        // Write the JSON data to the Web Request
                        StreamWriter writer = new StreamWriter(request.GetRequestStream());
                        writer.Write(jsonCity);
                        writer.Flush();
                        writer.Close();

                        // Read the data from the Web Response, which requires working with streams.
                        WebResponse  response      = request.GetResponse();
                        Stream       theDataStream = response.GetResponseStream();
                        StreamReader reader        = new StreamReader(theDataStream);
                        String       data          = reader.ReadToEnd();

                        reader.Close();
                        response.Close();

                        if (data == "ADDED")
                        {
                            lblWarning.Visible = true;
                            lblWarning.Text    = "Record Added";
                        }//end if
                        else
                        {
                            lblWarning.Visible = true;
                            lblWarning.Text    = data.ToString();
                        }//end else
                        container.InnerHtml = "";
                        container.InnerHtml = CityGUI.DisplayCities(getAllCities());
                    }
                    catch (Exception ex)
                    {
                        lblWarning.Visible = true;
                        lblWarning.Text    = "Error: " + ex.Message;
                    }
                } //end else
            }     //end if
            else
            {
                lblWarning.Visible = true;
                lblWarning.Text    = "All fields are required. Fields expecting a number will not accept letters";
            } //end else
        }     //end btnsubmit click
 protected void Page_Load(object sender, EventArgs e)
 {
     container.InnerHtml = CityGUI.DisplayCities(getAllCities());
 }
        }     //end btn search

        protected void btnSearch1_Click(object sender, EventArgs e)
        {
            if (!StringValidator.IsNotEmptySpaceOrNull(txtSearchState.Text))
            {
                lblWarning.Visible = false;
                string      cityName = txtSearchName.Text;
                WebRequest  request  = WebRequest.Create(webApiUrl + "CityByName" + "?cityName=" + cityName);
                WebResponse response = request.GetResponse();

                // Read the data from the Web Response, which requires working with streams.
                Stream       theDataStream = response.GetResponseStream();
                StreamReader reader        = new StreamReader(theDataStream);
                String       data          = reader.ReadToEnd();

                reader.Close();
                response.Close();

                // Deserialize a JSON string that contains an array of JSON objects into an Array of Team objects.
                JavaScriptSerializer js       = new JavaScriptSerializer();
                List <City>          CityList = js.Deserialize <List <City> >(data);
                if (CityList != null)
                {
                    container.InnerHtml = "";
                    container.InnerHtml = CityGUI.DisplayCities(CityList);
                }
                else
                {
                    lblWarning.Visible = true;
                    lblWarning.Text    = "No Records Found";
                }
            }//end if
            else if (StringValidator.IsNotEmptySpaceOrNull(txtSearchState.Text) &&
                     StringValidator.IsNotEmptySpaceOrNull(txtSearchName.Text))
            {
                lblWarning.Visible = false;
                string      cityState = txtSearchState.Text;
                string      cityName  = txtSearchName.Text;
                WebRequest  request   = WebRequest.Create(webApiUrl + "CityByNameAndState" + "?cityName=" + cityName + "&cityState=" + cityState);
                WebResponse response  = request.GetResponse();

                // Read the data from the Web Response, which requires working with streams.
                Stream       theDataStream = response.GetResponseStream();
                StreamReader reader        = new StreamReader(theDataStream);
                String       data          = reader.ReadToEnd();

                reader.Close();
                response.Close();

                // Deserialize a JSON string that contains an array of JSON objects into an Array of Team objects.
                JavaScriptSerializer js       = new JavaScriptSerializer();
                List <City>          CityList = js.Deserialize <List <City> >(data);
                if (CityList != null)
                {
                    container.InnerHtml = "";
                    container.InnerHtml = CityGUI.DisplayCities(CityList);
                }
                else
                {
                    lblWarning.Visible = true;
                    lblWarning.Text    = "No Records Found";
                }
            }//end else if
            else
            {
                lblWarning.Visible = false;
                string      cityState = txtSearchState.Text;
                WebRequest  request   = WebRequest.Create(webApiUrl + "CityByState" + "?cityState=" + cityState);
                WebResponse response  = request.GetResponse();

                // Read the data from the Web Response, which requires working with streams.
                Stream       theDataStream = response.GetResponseStream();
                StreamReader reader        = new StreamReader(theDataStream);
                String       data          = reader.ReadToEnd();

                reader.Close();
                response.Close();

                // Deserialize a JSON string that contains an array of JSON objects into an Array of Team objects.
                JavaScriptSerializer js       = new JavaScriptSerializer();
                List <City>          CityList = js.Deserialize <List <City> >(data);
                if (CityList != null)
                {
                    if (CityList.Count > 0)
                    {
                        container.InnerHtml = "";
                        container.InnerHtml = CityGUI.DisplayCities(CityList);
                    }//end if
                    else
                    {
                        lblWarning.Visible = true;
                        lblWarning.Text    = "No Records Found";
                    }//end else
                }
                else
                {
                    lblWarning.Visible = true;
                    lblWarning.Text    = "No Records Found";
                }
            }//end else if
        }