Inheritance: IPreset
        protected void lbNewSection_Click(object sender, EventArgs e)
        {
            lvSections.EditIndex          = -1;
            lvSections.InsertItemPosition = InsertItemPosition.FirstItem;
            ((LinkButton)sender).Visible  = false;
            Bind();

            var ddlPreset = lvSections.InsertItem.FindControl("ddlPreset") as DropDownList;

            if (ddlPreset == null)
            {
                return;
            }
            ddlPreset.DataSource     = Preset.All();
            ddlPreset.DataTextField  = "Name";
            ddlPreset.DataValueField = "ID";
            ddlPreset.DataBind();

            var pnlOwner = lvSections.InsertItem.FindControl("pnlOwner") as Panel;

            if (pnlOwner != null)
            {
                pnlOwner.Visible = User.IsInRole("administrator");
            }

            var ddlOwner = lvSections.InsertItem.FindControl("ddlOwner") as DropDownList;

            if (ddlOwner != null)
            {
                var users = Greenhouse.ByID(_webContext.GreenhouseIdSession).GreenhouseUsers;
                ddlOwner.DataSource     = users;
                ddlOwner.DataTextField  = "Username";
                ddlOwner.DataValueField = "UserID";
                ddlOwner.DataBind();
            }
        }
        public void lvSections_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            var litPresetID = e.Item.FindControl("litPresetID") as Literal;
            var ddlPreset   = e.Item.FindControl("ddlPreset") as DropDownList;

            if (ddlPreset != null)
            {
                ddlPreset.DataSource     = Preset.All();
                ddlPreset.DataTextField  = "Name";
                ddlPreset.DataValueField = "ID";
                if (litPresetID != null)
                {
                    ddlPreset.SelectedValue = litPresetID.Text;
                }
                ddlPreset.DataBind();
            }

            var pnlOwner = e.Item.FindControl("pnlOwner") as Panel;

            if (pnlOwner != null)
            {
                pnlOwner.Visible = User.IsInRole("administrator");
            }

            var litUserID = e.Item.FindControl("litUserID") as Literal;
            var ddlOwner  = e.Item.FindControl("ddlOwner") as DropDownList;

            if (ddlOwner != null)
            {
                var users = Greenhouse.ByID(_webContext.GreenhouseIdSession).GreenhouseUsers;
                ddlOwner.DataSource     = users;
                ddlOwner.DataTextField  = "Username";
                ddlOwner.DataValueField = "UserID";
                if (litUserID != null)
                {
                    ddlOwner.SelectedValue = litUserID.Text;
                }
                ddlOwner.DataBind();
            }

            var litIsTemperatureActivated = e.Item.FindControl("litIsTemperatureActivated") as Literal;
            var pnlTemperature            = e.Item.FindControl("pnlTemperature") as Panel;

            if (litIsTemperatureActivated != null)
            {
                if (pnlTemperature != null)
                {
                    pnlTemperature.Visible = bool.Parse(litIsTemperatureActivated.Text);
                }
            }

            var litIsLightActivated = e.Item.FindControl("litIsLightActivated") as Literal;
            var pnlLighting         = e.Item.FindControl("pnlLighting") as Panel;

            if (litIsLightActivated != null)
            {
                if (pnlLighting != null)
                {
                    pnlLighting.Visible = bool.Parse(litIsLightActivated.Text);
                }
            }

            var litIsHumidityActivated = e.Item.FindControl("litIsHumidityActivated") as Literal;
            var pnlHumidity            = e.Item.FindControl("pnlHumidity") as Panel;

            if (litIsHumidityActivated != null)
            {
                if (pnlHumidity != null)
                {
                    pnlHumidity.Visible = bool.Parse(litIsHumidityActivated.Text);
                }
            }

            var litIsWaterLevelActivated = e.Item.FindControl("litIsWaterLevelActivated") as Literal;
            var pnlWaterLevel            = e.Item.FindControl("pnlWaterLevel") as Panel;

            if (litIsWaterLevelActivated != null)
            {
                if (pnlWaterLevel != null)
                {
                    pnlWaterLevel.Visible = bool.Parse(litIsWaterLevelActivated.Text);
                }
            }

            var lblNoModules = e.Item.FindControl("lblNoModules") as Label;

            if (litIsTemperatureActivated != null &&
                litIsLightActivated != null &&
                litIsHumidityActivated != null &&
                litIsWaterLevelActivated != null)
            {
                if (!bool.Parse(litIsTemperatureActivated.Text) &&
                    !bool.Parse(litIsLightActivated.Text) &&
                    !bool.Parse(litIsHumidityActivated.Text) &&
                    !bool.Parse(litIsWaterLevelActivated.Text))
                {
                    if (lblNoModules != null)
                    {
                        lblNoModules.Visible = true;
                    }
                }
            }
        }