Пример #1
0
        /// <summary>
        /// 选写指定的项
        /// </summary>
        /// <param name="items"></param>
        /// <param name="value"></param>
        /// <param name="defaultValue"></param>
        public static void SelectByValue(this ListItemCollection items, string value, string defaultValue)
        {
            var item = items.FindByValue(value);

            if (item != null)
            {
                item = items.FindByValue(defaultValue);
            }
            if (item != null)
            {
                item.Selected = true;
            }
        }
Пример #2
0
    private string GetPara()
    {
        string para = "000000";

        string[]           paratable = new string[] { "$brand$", "$startDate$", "$endDate$", "$team$", "$merge$", "$month$" };
        ListItemCollection list      = new ListItemCollection();

        list = Paralist.Items;
        for (int i = 0; i < 6; i++)
        {
            if (list.FindByValue(paratable[i]) != null)
            {
                if (i == 0)
                {
                    para = "100000";
                }
                else if (i == 5)
                {
                    para = para.Substring(0, 5) + "1";
                }
                else
                {
                    para = para.Substring(0, i) + "1" + para.Substring(i + 1);
                }
            }
        }
        return(para);
    }
Пример #3
0
        public ListItemCollection GetMonth2(string selecteditem)
        {
            ListItemCollection lst = new ListItemCollection();

            lst = GetMonth();
            lst.IndexOf(lst.FindByValue(selecteditem));
            return(lst);
        }
Пример #4
0
        private void SelectItem(ListItemCollection items, string value)
        {
            ListItem selectingItem = items.FindByValue(value);

            if (selectingItem != null)
            {
                selectingItem.Selected = true;
            }
        }
        /// <summary>
        /// Actually performs binding the targetlist to the ListControl.
        /// </summary>
        protected override void DoBindTargetToSource(object source, object target, IDictionary <string, object> variables)
        {
            // retrieve targetlist
            IList targetList = this.GetTargetValue(target, variables) as IList;

            if (targetList == null)
            {
                throw new ArgumentException("Target property has to be initialized to an instance of IList interface.");
            }

            // retrieve ListControl to be bound
            source = this.GetSourceValue(source, variables);
            ListControl listControl = source as ListControl;

            if (listControl == null)
            {
                throw new ArgumentException(string.Format("Source property has to be initialized to an instance of {0}.", typeof(ListControl).FullName));
            }

            // clear control's selection
            listControl.ClearSelection();
            ListItemCollection listItems = listControl.Items;

            // set binding context if applicable
            IBindingAwareFormatter bindingAwareFormatter = this.Formatter as IBindingAwareFormatter;

            if (bindingAwareFormatter != null)
            {
                bindingAwareFormatter.SetBindingContext(source, target, variables, BindingDirection.TargetToSource);
            }

            // select all items in ListControl matching keys in targetlist
            try
            {
                IFormatter formatter = this.Formatter;
                foreach (object objectItem in targetList)
                {
                    string   key  = formatter.Format(objectItem);
                    ListItem item = listItems.FindByValue(key);
                    if (item != null)
                    {
                        item.Selected = true;
                    }
                    else
                    {
                        throw new ArgumentOutOfRangeException("value", key, string.Format("Value '{0}' does not exist", key));
                    }
                }
            }
            finally
            {
                if (bindingAwareFormatter != null)
                {
                    bindingAwareFormatter.ClearBindingContext();
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Sets the selected.
        /// </summary>
        /// <param name="lstItems">The LST items.</param>
        /// <param name="selectedValue">The selected value.</param>
        public static void SetSelected(ListItemCollection lstItems, string selectedValue)
        {
            ListItem item = lstItems.FindByValue(selectedValue);

            if (item != null)
            {
                item.Selected = true;
            }
        }
Пример #7
0
        public static void RemoveByValue(this ListItemCollection items, string value)
        {
            var item = items.FindByValue(value);

            if (item != null)
            {
                items.Remove(item);
            }
        }
Пример #8
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            try
            {
                //Export to excel from this dtPositions table.
                DataTable dtPositions = new DataTable();
                if (rcbOrganizationCode.SelectedIndex > 0)
                {
                    int  OrgCodeID = int.Parse(rcbOrganizationCode.SelectedValue);
                    bool includechildorgpositions       = chkChilldOrgCode.Checked;
                    bool includevacantpositions         = chkIncludeVacant.Checked;
                    ListItemCollection selecteditemlist = new ListItemCollection();
                    foreach (ListItem item in chkDataElements.Items)
                    {
                        if (item.Selected)
                        {
                            selecteditemlist.Add(item);
                        }
                    }
                    WorkforcePlanningPositionCollection listPositions = WorkforcePlanningPositionManager.Instance.GetPositionsByOrganizationCode(OrgCodeID, includechildorgpositions, includevacantpositions);
                    dtPositions = ControlUtility.ConvertToDataTable <WorkforcePlanningPosition>(listPositions);
                    //Issue: 3562: Custom Report: FPL Grade shows as -1 for vacancies
                    if (dtPositions.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dtPositions.Rows)
                        {
                            int fpl = int.Parse(dr["FPLGrade"].ToString());
                            if (fpl < 0)
                            {
                                dr["FPLGrade"] = System.DBNull.Value;
                            }
                        }
                    }
                    DataTable dtFinal = new DataTable();
                    dtFinal = dtPositions.Copy();
                    foreach (DataColumn dc in dtPositions.Columns)
                    {
                        string   colname = dc.ColumnName;
                        ListItem item    = selecteditemlist.FindByValue(colname);
                        if (item == null)
                        {
                            dtFinal.Columns.Remove(colname);
                            dtFinal.AcceptChanges();
                        }
                    }

                    Session["OrgPositions"]     = dtFinal;
                    Session["CustomReportsOrg"] = rcbOrganizationCode.Text;
                    base.SafeRedirect("~/Reports/OrgChartCustomReportExport.aspx");
                }
            }
            catch (Exception ex)
            {
                base.PrintErrorMessage(ex.Message, true);
            }
        }
Пример #9
0
        private TableCell CreateBlockTypeCell(
            string controlId,
            ContentType selectedPageType,
            ContentType disabledPageType)
        {
            TableCell    tableCell    = new TableCell();
            DropDownList dropDownList = new DropDownList();

            dropDownList.ID                    = controlId;
            dropDownList.DataSource            = _contentTypeRepository.List().OfType <BlockType>();
            dropDownList.AutoPostBack          = true;
            dropDownList.DataTextField         = "LocalizedName";
            dropDownList.DataValueField        = nameof(ID);
            dropDownList.SelectedIndexChanged += BlockTypeChanged;
            if (controlId == ToBlockTypeId)
            {
                _ddlTo = dropDownList;
            }

            tableCell.Style.Add("border-bottom", "none");
            tableCell.Controls.Add(dropDownList);
            tableCell.DataBind();

            int id;

            if (disabledPageType != null)
            {
                ListItemCollection items = dropDownList.Items;
                id = disabledPageType.ID;
                string   str     = id.ToString();
                ListItem byValue = items.FindByValue(str);
                if (byValue != null)
                {
                    dropDownList.Items.Remove(byValue);
                }
            }
            if (!(selectedPageType != null))
            {
                return(tableCell);
            }
            ListItemCollection items1 = dropDownList.Items;

            id = selectedPageType.ID;
            string   str1     = id.ToString();
            ListItem byValue1 = items1.FindByValue(str1);

            if (byValue1 == null)
            {
                return(tableCell);
            }
            byValue1.Selected = true;
            return(tableCell);
        }
Пример #10
0
 public static ListItem Find(this ListItemCollection items, IEntity entity)
 {
     if (entity == null)
     {
         return(null);
     }
     else
     {
         try { return(items.FindByValue(entity.GetId().ToString())); }
         catch { return(null); }
     }
 }
Пример #11
0
 //--------------------------------------------------------
 /// <summary>Selects a list item given the value</summary>
 /// <returns>True if value was located and selected</returns>
 public static bool SelectItemByValue(ListItemCollection list, string val)
 {
     try
     {
         list.FindByValue(val).Selected = true;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #12
0
        public static void SelectItems <T>(this ListItemCollection items, List <T> selectedItems)
        {
            foreach (T item in selectedItems)
            {
                ListItem li = items.FindByValue(Helper.Parse <String>(item));

                if (li != null)
                {
                    li.Selected = true;
                }
            }
        }
Пример #13
0
 protected string UpdateDivisionDDL2SelectedValue(object eval)
 {
     if (_currentRegionList != null)
     {
         ListItemCollection items = _currentRegionList.Items;
         if (eval == null || items.FindByValue(eval.ToString()) == null)
         {
             _currentRegionList = null;
             return(Guid.Empty.ToString());
         }
     }
     return(eval.ToString());
 }
Пример #14
0
        public static bool TrySelectByValue(this ListItemCollection collection, object value)
        {
            if (value == null || collection == null)
            {
                return(false);
            }
            ListItem item = collection.FindByValue(value.ToString());

            if (item != null)
            {
                return(item.Selected = true);
            }
            return(false);
        }
Пример #15
0
        public Boolean SelectListItem(ListItemCollection ListCollection, Int32 ItemSelect)
        {
            if (ListCollection == null)
            {
                return(false);
            }

            ListItem Item = ListCollection.FindByValue(ItemSelect.ToString());

            if (Item != null)
            {
                Item.Selected = true;
                return(true);
            }

            return(false);
        }
Пример #16
0
 public void BindCheckList(string checkedList)
 {
     cbAsrQma.DataSource = null;
     cbAsrQma.DataBind();
     BindCheckList();
     if (!string.IsNullOrEmpty(checkedList))
     {
         ListItemCollection listItems = cbAsrQma.Items;
         foreach (string val in checkedList.Split(','))
         {
             ListItem li = listItems.FindByValue(val);
             if (li != null)
             {
                 li.Selected = true;
             }
         }
     }
 }
Пример #17
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (this.Afiliado == null)
     {
         if (this.Context.Items["Afiliado"] != null)
         {
             this.Afiliado = this.Context.Items["Afiliado"] as IBBAV.Entidades.Afiliado;
         }
         else
         {
             base.Response.Redirect("~/login.aspx");
         }
     }
     if (this.Context.Items["type"] != null)
     {
         if (this.Context.Items["type"].ToString().Equals("0"))
         {
             this.liMensaje.Text = "Por su seguridad debe cambiar su clave y seleccionar el tiempo de caducidad de la misma.";
         }
         else
         {
             this.liMensaje.Text = "Su clave ha caducado, por favor cambie su clave por una nueva para seguir disfrutando de nuestros servicios.";
         }
     }
     if (!base.IsPostBack)
     {
         foreach (DataRow row in HelperGlobal.DiasPasswordGet().Tables[0].Rows)
         {
             this.ddlDiasCaducidad.Items.Add(new ListItem(row["Descripcion"].ToString(), row["Dias"].ToString()));
         }
         ListItemCollection items = this.ddlDiasCaducidad.Items;
         int      aFDiasPassword  = this.Afiliado.AF_DiasPassword;
         ListItem listItem        = items.FindByValue(aFDiasPassword.ToString());
         if (listItem != null)
         {
             listItem.Selected = true;
         }
         //Modificado 03/07/2018 por Liliana Guerra para activar insercion de datos por teclado en input clave
         //this.txtPassNew.Attributes.Add("readonly", "readonly");
         //this.txtPassNewConfirm.Attributes.Add("readonly", "readonly");
     }
 }
Пример #18
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //Modificado 03/07/2018 por Liliana Guerra para activar insercion de datos por teclado en input clave
     //this.txtPass.Attributes.Add("readonly", "readonly");
     //this.txtPassNew.Attributes.Add("readonly", "readonly");
     //this.txtPassNewConfirm.Attributes.Add("readonly", "readonly");
     if (!base.IsPostBack)
     {
         foreach (DataRow row in HelperGlobal.DiasPasswordGet().Tables[0].Rows)
         {
             this.ddlDiasCaducidad.Items.Add(new ListItem(row["Descripcion"].ToString(), row["Dias"].ToString()));
         }
         ListItemCollection items = this.ddlDiasCaducidad.Items;
         int      aFDiasPassword  = base.Afiliado.AF_DiasPassword;
         ListItem listItem        = items.FindByValue(aFDiasPassword.ToString());
         if (listItem != null)
         {
             listItem.Selected = true;
         }
     }
 }
Пример #19
0
        /// <summary> Called when the state of the control has changed between postbacks. </summary>
        protected override void RaisePostDataChangedEvent()
        {
            if (InternalValue == null)
            {
                _displayName = null;
            }
            else
            {
                ListItem selectedItem = _listItems.FindByValue(InternalValue);
                if (selectedItem == null)
                {
                    throw new InvalidOperationException(string.Format("The key '{0}' does not correspond to a known element.", InternalValue));
                }
                _displayName = selectedItem.Text;
            }

            if (!IsReadOnly && Enabled)
            {
                OnSelectionChanged();
            }
        }
Пример #20
0
        public void Methods()
        {
            ListItemCollection c;
            ListItem           i;
            ListItem           i2;

            c = new ListItemCollection();
            Assert.AreEqual(0, c.Count, "T1");

            i = new ListItem("Item 1", "10");
            c.Add(i);
            Assert.AreEqual(1, c.Count, "T2");

            i = new ListItem("This is item 2", "20");
            c.Add(i);
            Assert.AreEqual(2, c.Count, "T3");

            Assert.AreEqual(null, c.FindByText(" is "), "T4");
            Assert.AreEqual(i.Text, c.FindByText("This is item 2").Text, "T5");
            Assert.AreSame(i, c.FindByText("This is item 2"), "T6");
            Assert.AreEqual(1, c.IndexOf(c.FindByText("This is item 2")), "T7");
            Assert.AreEqual(1, c.IndexOf(c.FindByValue("20")), "T8");

            i = new ListItem("Item 3", "30");
            Assert.IsFalse(c.Contains(i), "T9");
            c.Add(i);
            Assert.IsTrue(c.Contains(i), "T10");

            i  = new ListItem("Forth", "40");
            i2 = new ListItem("Fifth", "50");
            c.AddRange(new ListItem[] { i, i2 });
            Assert.AreEqual(5, c.Count, "T11");

            c.RemoveAt(1);
            Assert.AreEqual(4, c.Count, "T12");
            Assert.AreEqual(null, c.FindByText("This is item 2"), "T13");

            c.Clear();
            Assert.AreEqual(0, c.Count, "T13");
        }
Пример #21
0
    private void SynList()
    {
        ArrayList          arrayValue     = new ArrayList(TextBoxSynOrder.Text.Split(','));
        ListItemCollection itemCollection = new ListItemCollection();

        itemCollection.AddRange((ListItem[])new ArrayList(ListBoxLeft.Items).ToArray(typeof(ListItem)));
        itemCollection.AddRange((ListItem[])new ArrayList(ListBoxRight.Items).ToArray(typeof(ListItem)));

        ListBoxLeft.Items.Clear();
        ListBoxRight.Items.Clear();
        for (int i = 0; i < arrayValue.Count; i++)
        {
            ListItem item = itemCollection.FindByValue(arrayValue[i].ToString());
            if (item != null)
            {
                ListBoxRight.Items.Add(item);

                itemCollection.Remove(item);
            }
        }
        ListBoxLeft.Items.AddRange((ListItem[])new ArrayList(itemCollection).ToArray(typeof(ListItem)));
    }
    protected void loadGeoLocItems(ListItemCollection uiListBox, int fieldNum)
    {
        string fileName;

        string[]  fieldNames = { "" };
        ArrayList dataArray;
        string    appPath = Request.PhysicalApplicationPath; // requires System.Diagnostics

        fileName = appPath + "\\vegData\\PSP_stand_info_subset_2015.csv";

        uiListBox.Add(new ListItem("Select location"));

        dataArray = readCSV(fileName, ref fieldNames);
        foreach (string[] dataLine in dataArray)
        {
            if (uiListBox.FindByValue(dataLine[fieldNum]) == null && dataLine[fieldNum] != "SQNP" && dataLine[fieldNum] != "RockyMtns")
            {
                uiListBox.Add(new ListItem(getReadableText(dataLine[fieldNum]), dataLine[fieldNum]));
            }
        }

        uiListBox.Add(new ListItem("Mount Rainier National Park", "MRRS"));
    }
Пример #23
0
        public static void CreateHoursList(ListItemCollection ListItems, SortDirection direction)
        {
            int from = 0, to = 23, step = 1;

            if (direction == SortDirection.Descending)
            {
                from = 23; to = 0; step = -1;
            }

            if (Micajah.Common.Security.UserContext.Current.TimeFormat == 0) //AM/PM time format
            {
                for (int i = from; (direction == SortDirection.Ascending && i <= to) || (direction == SortDirection.Descending && i >= to); i += step)
                {
                    if (i < 12)
                    {
                        ListItems.Add(new ListItem(i.ToString() + "am", i.ToString()));
                    }
                    else if (i > 12)
                    {
                        ListItems.Add(new ListItem((i - 12).ToString() + "pm", i.ToString()));
                    }
                    else
                    {
                        ListItems.Add(new ListItem(i.ToString() + "noon", i.ToString()));
                    }
                }

                ListItems.FindByValue("0").Text = "12am";
            }
            else
            {
                for (int i = from; (direction == SortDirection.Ascending && i <= to) || (direction == SortDirection.Descending && i >= to); i += step)
                {
                    ListItems.Add(new ListItem(FormatTimePart(i), i.ToString()));
                }
            }
        }
Пример #24
0
        protected string ProjectWhereString()
        {
            StringBuilder ret = new StringBuilder();

            ListItemCollection items_ = new ListItemCollection();

            foreach (ListItem itm in DDLProject.Items)
            {
                items_.Add(itm);
            }

            items_.Remove(items_.FindByValue("0"));

            for (int i = 0; i < items_.Count; i++)
            {
                ret.Append(string.Format("'{0}'", items_[i].Value));

                if (i < items_.Count - 1)
                {
                    ret.Append(",");
                }
            }
            return(ret.ToString());
        }
Пример #25
0
        bool IPostBackDataHandler.LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            string str = postCollection[Configuration.HttpModule.IdPrefix + ClientID];

            if (!string.IsNullOrEmpty(str))
            {
                ListItemCollection ListaVelha = new ListItemCollection();

                ListItem[] arrTemp = new ListItem[this.Items.Count];
                this.Items.CopyTo(arrTemp, 0);
                this.Items.Clear();

                ListaVelha.AddRange(arrTemp);

                string[] ordens = str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string i in ordens)
                {
                    this.Items.Add(ListaVelha.FindByValue(i));
                }

                OnOrderChanged();
            }
            return(true);
        }
        private void populateInvoiceOptions()
        {
            if (_shoppingCart != null && _shoppingCart.DeliveryInfo != null)
            {
                //divInvoiceOptions
                if (_invoiceOptionRBL != null)
                {
                    divInvoiceOptions.Controls.Remove(_invoiceOptionRBL);
                }
                _invoiceOptionRBL = new RadioButtonList();
                _invoiceOptionRBL.EnableViewState = true;
                ListItemCollection result = new ListItemCollection();

                CatalogItemList catItems = CatalogProvider.GetCatalogItems((from c in _shoppingCart.CartItems
                                                                            select c.SKU.Trim()).ToList <string>(),
                                                                           (this.Page as ProductsBase).CountryCode);
                var list = new List <CatalogItem_V01>();
                list.AddRange(catItems.Select(c => c.Value as CatalogItem_V01).ToList <CatalogItem_V01>());
                var invoiceOptions = new List <InvoiceHandlingType>();
                invoiceOptions = ShippingProvider.GetInvoiceOptions(_shoppingCart.DeliveryInfo.Address, list,
                                                                    this.ShoppingCart);
                //CR for Argies and MX
                if (!HLConfigManager.Configurations.CheckoutConfiguration.AlwaysDisplayInvoiceOption &&
                    (null == invoiceOptions || invoiceOptions.Count == 0))
                {
                    this.Visible      = false;
                    _invoiceOptionRBL = null;
                    return;
                }

                var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("InvoiceOptions");

                foreach (var entry in entries)
                {
                    var key   = entry.Key;
                    var parts = key.Split('_');
                    if (parts.Length > 1)
                    {
                        key = parts[0];
                    }
                    var value = entry.Value;
                    if (result.FindByValue(key) == null)
                    {
                        if (invoiceOptions != null)
                        {
                            if (
                                invoiceOptions.Exists(
                                    c => c == (InvoiceHandlingType)Enum.Parse(typeof(InvoiceHandlingType), key)))
                            {
                                var newItem = new ListItem(value, key);
                                if (_invoiceOptionRBL.Items.FindByValue(key) == null)
                                {
                                    _invoiceOptionRBL.Items.Add(newItem);
                                }
                            }
                        }
                        else
                        {
                            _invoiceOptionRBL.Items.Add(new ListItem(value, key));
                        }
                    }
                }
                if (_invoiceOptionRBL.Items.Count > 0)
                {
                    if (!HLConfigManager.Configurations.CheckoutConfiguration.DisableDefaultInvoiceOption)
                    {
                        ListItem defaultOption = null;
                        if (!string.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.DefaultInvoiceOption))
                        {
                            defaultOption =
                                _invoiceOptionRBL.Items.FindByValue(
                                    HLConfigManager.Configurations.CheckoutConfiguration.DefaultInvoiceOption);
                        }
                        if (defaultOption == null && _shoppingCart.Locale != "zh-TW")
                        {
                            // Selecting the first from Shipping rules.
                            defaultOption = _invoiceOptionRBL.Items.FindByValue(invoiceOptions[0].ToString());
                        }
                        if (defaultOption != null)
                        {
                            defaultOption.Selected = true;
                        }
                        else
                        {
                            if (_shoppingCart.Locale == "zh-TW" && _invoiceOptionRBL.Items.Count > 1)
                            {
                                _invoiceOptionRBL.Items[1].Selected = true;
                            }
                            else
                            {
                                _invoiceOptionRBL.Items[0].Selected = true;
                            }
                        }
                    }
                }

                if (_invoiceOptionRBL.Items.Count > 0)
                {
                    _invoiceOptionRBL.AutoPostBack          = true;
                    _invoiceOptionRBL.SelectedIndexChanged += new EventHandler(_invoiceOptionRBL_SelectedIndexChanged);
                }

                divInvoiceOptions.Controls.Add(_invoiceOptionRBL);
            }
        }
Пример #27
0
        public static string EnumToString <T>(T value)
        {
            ListItemCollection lists = EnumToList <T>();

            return(lists.FindByValue(value.ToString()).Text);
        }