/// <summary>
        /// sets up the edit page
        /// </summary>
        private void LoadExistingData()
        {
            var list       = DataProvider.GetBTBWeatherFeedByModule(this.ModuleId);
            var controller = new BTBWeatherFeedController();


            //sort the list by location name
            lstLocations.DataSource = list.OrderBy(w => w.LocationName);
            lstLocations.DataBind();


            //if we have one or more feed get the current temperature unit
            //we need this to set the correct radio button checked
            if (list.Count() > 0)
            {
                BTBWeatherFeedInfo info = (BTBWeatherFeedInfo)list.First();
                BTBWeatherFeedController.TemperatureScale tempScale = controller.ExtractTemperatureScaleFromUrl(info.Url);

                if (tempScale == BTBWeatherFeedController.TemperatureScale.Celsius)
                {
                    rbTempC.Checked = true;
                }
                else
                {
                    rbTempF.Checked = true;
                }

                ViewState[VIEWSTATE_TEMPERATURE_SCALE] = tempScale;

                //setup the default weather feed
                ddlDefaultFeed.DataValueField = "WeatherId";
                ddlDefaultFeed.DataTextField  = "LocationName";
                ddlDefaultFeed.DataSource     = list;
                ddlDefaultFeed.DataBind();

                //set the default feed
                BTBWeatherFeedInfo defaultWeatherFeed = controller.GetDefaultFeed(list);
                if (defaultWeatherFeed != null)
                {
                    ddlDefaultFeed.Enabled       = true;
                    ddlDefaultFeed.SelectedValue = defaultWeatherFeed.WeatherId.ToString();
                }
            }
            else
            {
                ddlDefaultFeed.Enabled = false;
            }

            //load all the xlst templates
            LoadTemplateFiles("Xslt", ddlXsltTemplates);

            //load all the razor templates
            LoadTemplateFiles("Razor", ddlRazorTemplates);


            if (ModuleSettings.RenderEngine == BTBYahooWeatherSettings.TemplateEngine.Xlst)
            {
                rbXlst.Checked = true;
                var item = ddlXsltTemplates.Items.FindByText(ModuleSettings.TemplateName);
                if (item != null)
                {
                    item.Selected = true;
                }
            }
            else
            {
                rbRazor.Checked = true;
                var item = ddlRazorTemplates.Items.FindByText(ModuleSettings.TemplateName);
                if (item != null)
                {
                    item.Selected = true;
                }
            }


            //load the flag to determine if we allow the user to persist the selected
            //weather location
            chkUserPersist.Checked = ModuleSettings.AllowUserPersonialisation;
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                jQuery.RequestRegistration();

                BTBWeatherFeedController controller = new BTBWeatherFeedController();
                BTBWeatherFeedInfo       info;
                if (!Page.IsPostBack)
                {
                    var weatherFeeds = DataProvider.GetBTBWeatherFeedByModule(ModuleId);

                    if ((weatherFeeds == null))
                    {
                        //this module does not have a configured
                        //weather feed, info the user
                        DotNetNuke.UI.Skins.Skin.AddModuleMessage(this,
                                                                  Localization.GetString("FeedNotSet.Text", this.LocalResourceFile),
                                                                  DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError);
                        return;
                    }


                    if (weatherFeeds.Count() > 1)
                    {
                        ValidateFeedsHaveLocationName(weatherFeeds);

                        pnlDropDown.Visible         = true;
                        ddlLocations.DataTextField  = "LocationName";
                        ddlLocations.DataValueField = "WeatherId";

                        ddlLocations.DataSource = weatherFeeds.OrderBy(w => w.LocationName);
                        ddlLocations.DataBind();
                    }

                    //check if we should load the users selected weather feed
                    if (ModuleSettings.AllowUserPersonialisation && HttpContext.Current.User.Identity.IsAuthenticated)
                    {
                        //check if the user has selected otherwise just let the
                        //default location pick the selection

                        DotNetNuke.Entities.Users.UserInfo curUser = UserController.GetUserById(PortalId, UserId);
                        string location = curUser.Profile.GetPropertyValue(USER_PERSONIALISATION);
                        if (location != null)
                        {
                            BTBWeatherFeedInfo userSelectWFI = null;
                            int locationId = -1;

                            int.TryParse(location, out locationId);

                            foreach (BTBWeatherFeedInfo item in weatherFeeds)
                            {
                                if (item.WeatherId == locationId)
                                {
                                    userSelectWFI = item;
                                    break;
                                }
                            }

                            if (userSelectWFI != null)
                            {
                                ddlLocations.SelectedValue = userSelectWFI.WeatherId.ToString();
                                DisplayFeed(userSelectWFI);
                                return;
                            }
                        }
                    }


                    //check if we have a default feed, overwise show the first time
                    BTBWeatherFeedInfo defaultInfo = controller.GetDefaultFeed(weatherFeeds);
                    if (defaultInfo != null)
                    {
                        info = defaultInfo;
                        ddlLocations.SelectedValue = defaultInfo.WeatherId.ToString();
                    }
                    else
                    {
                        info = weatherFeeds.FirstOrDefault();
                    }

                    DisplayFeed(info);
                }
            }
            catch (System.Net.WebException exc)
            {
                //this will bubble up from the call to the update feed if we have a connection
                //problem to the remote RSS feed

                //output something to the user control to tell the user we have a problem
                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this,
                                                          Localization.GetString("WebException.Text", this.LocalResourceFile),
                                                          DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError);

                //log the details in the event log for the admin to see
                Exceptions.LogException(exc);
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }