Exemplo n.º 1
0
    private void FillTimeZones()
    {
        ITimeZoneService service = null;

        try
        {
            // Create the service.
            service            = AppService.Create <ITimeZoneService>();
            service.AppManager = this.AppManager;
            List <Tks.Entities.TimeZone> timeZones = service.RetrieveAll();

            // Filter valid time zones.
            IEnumerable <Tks.Entities.TimeZone> validList = from item in timeZones
                                                            where item.IsActive = true
                                                                                  select item;

            // Bind.
            this.ddlMiscActivityTimeZoneList.Items.Clear();
            this.ddlMiscActivityTimeZoneList.DataTextField  = "Name";
            this.ddlMiscActivityTimeZoneList.DataValueField = "Id";
            this.ddlMiscActivityTimeZoneList.DataSource     = validList;
            this.ddlMiscActivityTimeZoneList.DataBind();

            // Add default item.
            this.ddlMiscActivityTimeZoneList.Items.Insert(0, new ListItem("-- Select --", "0"));

            // Select first item as default.
            if (this.ddlMiscActivityTimeZoneList.Items.Count > 0)
            {
                this.ddlMiscActivityTimeZoneList.SelectedIndex = 0;
            }
            if (this.ddlMiscActivityTimeZoneList.Items.Count == 2)
            {
                this.ddlMiscActivityTimeZoneList.SelectedIndex = 1;
            }
        }
        catch { throw; }
        finally
        {
            if (service != null)
            {
                service.Dispose();
            }
        }
    }
    private void FillTimeZoneList()
    {
        ITimeZoneService service = null;

        try
        {
            // Create the service.
            service            = AppService.Create <ITimeZoneService>();
            service.AppManager = this.AppManager;

            // Call method.
            mTimeZones = service.RetrieveAll();
            // Filter active time zones.
            IEnumerable <Tks.Entities.TimeZone> validTimeZones = from item in mTimeZones
                                                                 where item.IsActive = true
                                                                                       select item;

            // Fill in control.
            this.ddlTimeZoneList.Items.Clear();
            this.ddlTimeZoneList.DataTextField  = "Name";
            this.ddlTimeZoneList.DataValueField = "Id";
            this.ddlTimeZoneList.DataSource     = validTimeZones;
            this.ddlTimeZoneList.DataBind();

            // Add default item.
            this.ddlTimeZoneList.Items.Insert(0, new ListItem("-- Select --", "0"));


            // Select first item as default.
            //if (this.ddlTimeZoneList.Items.Count > 0) this.ddlTimeZoneList.Items.FindByValue("0").Selected=true;
        }
        catch { throw; }
        finally
        {
            if (service != null)
            {
                service.Dispose();
            }
        }
    }