//Perform housekeeping on page load
        protected void Page_Load(object sender, EventArgs e)
        {
            if (WebWeather.allowUser == false)
            {
                Response.Redirect("~/Login");
            }
            else
            {
                if (!IsPostBack)
                {
                    WebWeather.PopulateWeatherArrayLists();
                    dt = new DataTable();
                    dt.Columns.Add(new DataColumn("City", typeof(string)));
                    dt.Columns.Add(new DataColumn("Date", typeof(string)));
                    dt.Columns.Add(new DataColumn("Min Temp", typeof(string)));
                    dt.Columns.Add(new DataColumn("Max Temp", typeof(string)));
                    dt.Columns.Add(new DataColumn("Precipitation", typeof(string)));
                    dt.Columns.Add(new DataColumn("Humidity", typeof(string)));
                    dt.Columns.Add(new DataColumn("Wind Speed", typeof(string)));

                    DataRow row = dt.NewRow();
                    dt.Rows.Add(row);
                    reportGrid.DataSource = dt;
                    reportGrid.DataBind();
                    SecondDate_SelectionChanged(sender, e);
                    PopulateCityComboBox();
                }
                GetUsualCities();
                UpdateCityBox();
                GetWeatherTable();
            }
        }
 //Populate the report city selection combo box
 private void PopulateCityComboBox()
 {
     cities.Items.Clear();
     for (int i = 0; i < (WebWeather.GetCityNameCount()); i++)
     {
         if (cities.Items.Contains(new ListItem(WebWeather.GetCityName(i))))
         {
         }
         else
         {
             cities.Items.Add(new ListItem(WebWeather.GetCityName(i)));
         }
     }
     cities.Items.Add(new ListItem("Select a City..."));
     cities.SelectedValue = "Select a City...";
 }
        //Update gridview with requested weather data
        private void GetWeatherTable()
        {
            reportGrid.DataSource = null;
            reportGrid.DataBind();
            dt = new DataTable();

            dt.Columns.Add(new DataColumn("City", typeof(string)));
            dt.Columns.Add(new DataColumn("Date", typeof(string)));
            dt.Columns.Add(new DataColumn("Min Temp", typeof(string)));
            dt.Columns.Add(new DataColumn("Max Temp", typeof(string)));
            dt.Columns.Add(new DataColumn("Precipitation", typeof(string)));
            dt.Columns.Add(new DataColumn("Humidity", typeof(string)));
            dt.Columns.Add(new DataColumn("Wind Speed", typeof(string)));

            DataRow row;

            int lowMinTemp  = 0;
            int highMinTemp = 0;
            int lowMaxTemp  = 0;
            int highMaxTemp = 0;
            int lowPrecip   = 0;
            int highPrecip  = 0;
            int lowHumid    = 0;
            int highHumid   = 0;
            int lowSpeed    = 0;
            int highSpeed   = 0;

            if (citiesSelected.Count != 0)
            {
                for (int j = 0; j < citiesSelected.Count; j++)
                {
                    for (int i = 0; i < WebWeather.GetCityNameCount(); i++)
                    {
                        if (WebWeather.GetCityName(i) == Convert.ToString(citiesSelected[j]))
                        {
                            if (WebWeather.GetWeatherDate(i) >= firstDate.SelectedDate && WebWeather.GetWeatherDate(i) <= secondDate.SelectedDate)
                            {
                                if (dt.Rows.Count == 0)
                                {
                                    //Initiate values in the lowest and highest section
                                    lowMinTemp  = Convert.ToInt32(WebWeather.GetMinTemp(i));
                                    highMinTemp = Convert.ToInt32(WebWeather.GetMinTemp(i));
                                    lowMaxTemp  = Convert.ToInt32(WebWeather.GetMaxTemp(i));
                                    highMaxTemp = Convert.ToInt32(WebWeather.GetMaxTemp(i));
                                    lowPrecip   = Convert.ToInt32(WebWeather.GetPrecipitation(i));
                                    highPrecip  = Convert.ToInt32(WebWeather.GetPrecipitation(i));
                                    lowHumid    = Convert.ToInt32(WebWeather.GetHumidity(i));
                                    highHumid   = Convert.ToInt32(WebWeather.GetHumidity(i));
                                    lowSpeed    = Convert.ToInt32(WebWeather.GetWindSpeed(i));
                                    highSpeed   = Convert.ToInt32(WebWeather.GetWindSpeed(i));
                                }
                                else
                                {
                                    //Update values if lowest and highest section not empty
                                    if (Convert.ToInt32(WebWeather.GetMinTemp(i)) < lowMinTemp)
                                    {
                                        lowMinTemp = Convert.ToInt32(WebWeather.GetMinTemp(i));
                                    }

                                    if (Convert.ToInt32(WebWeather.GetMinTemp(i)) > highMinTemp)
                                    {
                                        highMinTemp = Convert.ToInt32(WebWeather.GetMinTemp(i));
                                    }

                                    if (Convert.ToInt32(WebWeather.GetMaxTemp(i)) < lowMaxTemp)
                                    {
                                        lowMaxTemp = Convert.ToInt32(WebWeather.GetMaxTemp(i));
                                    }

                                    if (Convert.ToInt32(WebWeather.GetMaxTemp(i)) > highMaxTemp)
                                    {
                                        highMaxTemp = Convert.ToInt32(WebWeather.GetMaxTemp(i));
                                    }

                                    if (Convert.ToInt32(WebWeather.GetPrecipitation(i)) < lowPrecip)
                                    {
                                        lowPrecip = Convert.ToInt32(WebWeather.GetPrecipitation(i));
                                    }

                                    if (Convert.ToInt32(WebWeather.GetPrecipitation(i)) > highPrecip)
                                    {
                                        highPrecip = Convert.ToInt32(WebWeather.GetPrecipitation(i));
                                    }

                                    if (Convert.ToInt32(WebWeather.GetHumidity(i)) < lowHumid)
                                    {
                                        lowHumid = Convert.ToInt32(WebWeather.GetHumidity(i));
                                    }

                                    if (Convert.ToInt32(WebWeather.GetHumidity(i)) > highHumid)
                                    {
                                        highHumid = Convert.ToInt32(WebWeather.GetHumidity(i));
                                    }

                                    if (Convert.ToInt32(WebWeather.GetWindSpeed(i)) < lowSpeed)
                                    {
                                        lowSpeed = Convert.ToInt32(WebWeather.GetWindSpeed(i));
                                    }

                                    if (Convert.ToInt32(WebWeather.GetWindSpeed(i)) > highSpeed)
                                    {
                                        highSpeed = Convert.ToInt32(WebWeather.GetWindSpeed(i));
                                    }
                                }
                                row                  = dt.NewRow();
                                row["City"]          = WebWeather.GetCityName(i);
                                row["Date"]          = WebWeather.GetWeatherDate(i).ToShortDateString();
                                row["Min Temp"]      = WebWeather.GetMinTemp(i) + "°C";
                                row["Max Temp"]      = WebWeather.GetMaxTemp(i) + "°C";
                                row["Precipitation"] = WebWeather.GetPrecipitation(i) + "%";
                                row["Humidity"]      = WebWeather.GetHumidity(i) + "%";
                                row["Wind Speed"]    = WebWeather.GetWindSpeed(i) + " km/h";
                                dt.Rows.Add(row);

                                //Update Lowest/Highest section
                                lowestMinTemp.Text  = "Min Temp: " + Convert.ToString(lowMinTemp) + " °C";
                                highestMinTemp.Text = "Min Temp: " + Convert.ToString(highMinTemp) + " °C";

                                lowestMaxTemp.Text  = "Max Temp: " + Convert.ToString(lowMaxTemp) + " °C";
                                highestMaxTemp.Text = "Max Temp: " + Convert.ToString(highMaxTemp) + " °C";

                                lowestPrecip.Text  = "Precipitation: " + Convert.ToString(lowPrecip) + " %";
                                highestPrecip.Text = "Precipitation: " + Convert.ToString(highPrecip) + " %";

                                lowestHumid.Text  = "Humidity: " + Convert.ToString(lowHumid) + " %";
                                highestHumid.Text = "Humidity: " + Convert.ToString(highHumid) + " %";

                                lowestWind.Text  = "Wind Speed: " + Convert.ToString(lowSpeed) + " km/h";
                                highestWind.Text = "Wind Speed: " + Convert.ToString(highSpeed) + " km/h";
                            }
                        }
                    }
                }
                //Reset report and display error
                if (dt.Rows.Count == 0)
                {
                    lowestMinTemp.Text  = "Min Temp: ";
                    highestMinTemp.Text = "Min Temp: ";
                    lowestMaxTemp.Text  = "Max Temp: ";
                    highestMaxTemp.Text = "Max Temp: ";
                    lowestPrecip.Text   = "Precipitation: ";
                    highestPrecip.Text  = "Precipitation: ";
                    lowestHumid.Text    = "Humidity: ";
                    highestHumid.Text   = "Humidity: ";
                    lowestWind.Text     = "Wind Speed: ";
                    highestWind.Text    = "Wind Speed: ";
                    Response.Write("<script>alert('No Results Found!');</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('You have not selected any cities. To obtain results, please select one or more cities.');</script>");
            }
            reportGrid.DataSource = dt;
            reportGrid.DataBind();
        }